Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unauthorized type 3 #114

Open
pmagnuson opened this issue Feb 17, 2020 · 5 comments
Open

Unauthorized type 3 #114

pmagnuson opened this issue Feb 17, 2020 · 5 comments

Comments

@pmagnuson
Copy link

Following the example code of

import 'package:postgres/postgres.dart';

void main() async {
  print('Hello World!');

  var connection = new PostgreSQLConnection("127.0.0.1", 5432, "xxx",
      username: "xx", password: "xxx");
  await connection.open();
}

produces the error
PostgreSQLSeverity.error : Unsupported authentication type 3, closing connection.

I verified that the connection parameters work by using the same with psql on this database.
The full stack trace is

Unhandled exception:
PostgreSQLSeverity.error : Unsupported authentication type 3, closing connection. 
#0      PostgreSQLConnection.open (package:postgres/src/connection.dart:154:7)
<asynchronous suspension>
#1      main (file:///Users/philm/Documents/projects/dart_sql/main.dart:25:20)
#2      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19)
#3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
@isoos
Copy link
Collaborator

isoos commented Feb 17, 2020

@pmagnuson: psql may connect through Unix socket too, please double check with another tool. It is likely that either the password auth is disabled, or the source IP is not enabled (is there any networking involved?)...

@pmagnuson
Copy link
Author

pmagnuson commented Feb 17, 2020 via email

@joeconwaystk
Copy link
Contributor

joeconwaystk commented Feb 17, 2020

This library does not implement the cleartext password authentication method in the frontend/backend protocol; it only implements the md5 password method. If you wanted to implement this method, check out the docs for the authentication messages the client/server send here.

  1. You'll need to create a new message type for any new client or server messages, like this one:
    class AuthenticationMessage implements ServerMessage {
  2. You'll react to this new message in this method:
    _PostgreSQLConnectionState onMessage(ServerMessage message) {

You might need new state types (like the class that method belongs to) to handle the different states the connection will be in for the differing authentication methods. I believe the clear text method you want to use requires an authentication challenge and would require a state to respond to this challenge. You'll also note the error message you are seeing in your issue is located in this method.

  1. There might be API changes in the library if there is some user choice around what authentication method.

edit: Or optionally allow md5 authentication type in your postgres config, if possible.

@oysterpack
Copy link

I am running into the same exact issue with cockroachdb - which is a blocker.

being able to connect via a secure connection is a must have ... are there any plans to address this?

@isoos
Copy link
Collaborator

isoos commented Jul 7, 2020

fwiw, I'm using cockroachdb with insecure setup + wireguard to connect the nodes and the clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants