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

C# MongoDB driver: "no PostgreSQL user name specified in startup packet" #4065

Closed
Evengard opened this issue Feb 12, 2024 · 5 comments · Fixed by #4549, #4550 or #4552
Closed

C# MongoDB driver: "no PostgreSQL user name specified in startup packet" #4065

Evengard opened this issue Feb 12, 2024 · 5 comments · Fixed by #4549, #4550 or #4552
Assignees
Labels
area/auth Issues about authentication and authorization code/bug Some user-visible feature works incorrectly not ready Issues that are not ready to be worked on; PRs that should skip CI
Milestone

Comments

@Evengard
Copy link
Contributor

Evengard commented Feb 12, 2024

FerretDB version

1.19.0

Backend

PostgreSQL 15.2

Environment

  • OS: Debian 11.8
  • Deployment: k8s deployment
  • Deployment details: Both FerretDB and PostgreSQL are deployed in an k8s instance

What did you do?

I either can't authenticate at all (if not using StableAPI), or can't Insert documents (if using the StableAPI).

Consider this sample which will fail no matter if I set StableAPI or not:

using MongoDB.Driver;

var mongoClientSettings = MongoClientSettings.FromConnectionString("mongodb://username:password@myferretdb:25017/?authMechanism=PLAIN");
mongoClientSettings.ServerApi = new ServerApi(ServerApiVersion.V1);
var mongoClient = new MongoClient(mongoClientSettings);
var mongoDb = mongoClient.GetDatabase("dm3dev");
var collection = mongoDb.GetCollection<Test>("test");
collection.InsertOne(new Test("World"));

public record Test(string Hello);

If I run it as it is, I get 'Command insert failed: insert: unknown field "apiVersion".', which seems to be related to #3121

If I run it without the line mongoClientSettings.ServerApi = new ServerApi(ServerApiVersion.V1); which sets the StableAPI, I then get:

'Command insert failed: [msg_insert.go:169 handler.(*Handler).MsgInsert] [collection.go:123 postgresql.(*collection).InsertAll] [registry.go:479 metadata.(*Registry).CollectionCreate] [registry.go:132 metadata.(*Registry).getPool] [pool.go:128 pool.(*Pool).Get] [opendb.go:95 pool.openDB] [opendb.go:110 pool.checkConnection] failed to connect tohost=postgres-db-rw.postgres.svc.cluster.local user= database=dm3_ferret_dev: server error (FATAL: no PostgreSQL user name specified in startup packet (SQLSTATE 28000)).'

Which looks like the username from the client isn't passed down to the Postgres server.

What did you expect to see?

I expect it to work at least with some settings...

@Evengard Evengard added code/bug Some user-visible feature works incorrectly not ready Issues that are not ready to be worked on; PRs that should skip CI labels Feb 12, 2024
@Evengard
Copy link
Contributor Author

Evengard commented Feb 12, 2024

Please note that I'm using this postgresql setting:

- name: FERRETDB_POSTGRESQL_URL
  value: "postgres://postgres-db-rw.postgres.svc.cluster.local:5432/dm3_ferret_dev"

I explicitely did not provide a username and password here, as I need to restrict anonymous logins completely.

@AlekSi
Copy link
Member

AlekSi commented Feb 12, 2024

What is your driver version?

@AlekSi AlekSi added the community Issues and PRs assigned to community members label Feb 12, 2024
@AlekSi AlekSi assigned Evengard and unassigned ferretdb-bot Feb 12, 2024
@b1ron
Copy link
Contributor

b1ron commented Feb 12, 2024

@AlekSi I suspect 2.15 or older see this comment.

@Evengard
Copy link
Contributor Author

As I said in the PR, it is 2.23.1

@AlekSi
Copy link
Member

AlekSi commented Feb 13, 2024

First of all, we should be able to reproduce that issue with dance. That's on @b1ron (FerretDB/dance#769)

@AlekSi AlekSi self-assigned this Apr 15, 2024
@AlekSi AlekSi added the area/auth Issues about authentication and authorization label Jul 22, 2024
@AlekSi AlekSi added this to the Next milestone Aug 19, 2024
@AlekSi AlekSi removed the community Issues and PRs assigned to community members label Aug 21, 2024
@AlekSi AlekSi closed this as completed Aug 23, 2024
@AlekSi AlekSi reopened this Aug 23, 2024
@AlekSi AlekSi reopened this Aug 26, 2024
@AlekSi AlekSi reopened this Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/auth Issues about authentication and authorization code/bug Some user-visible feature works incorrectly not ready Issues that are not ready to be worked on; PRs that should skip CI
Projects
Archived in project
5 participants