https://github.com/softinstigate/java-mongodb-driver-ferretdb-auth-issue
This is a reproducer of an issue with the MongoDb Java Driver authentication with FerretDb 0.9.0.
https://github.com/softinstigate/java-mongodb-driver-ferretdb-auth-issue
Last synced: 11 months ago
JSON representation
This is a reproducer of an issue with the MongoDb Java Driver authentication with FerretDb 0.9.0.
- Host: GitHub
- URL: https://github.com/softinstigate/java-mongodb-driver-ferretdb-auth-issue
- Owner: SoftInstigate
- License: apache-2.0
- Created: 2023-01-31T16:50:34.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-10T18:03:48.000Z (over 3 years ago)
- Last Synced: 2025-05-13T21:49:15.962Z (12 months ago)
- Language: Java
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Java MongoDbDriver FerretDb Auth Issue
This is a reproducer of an issue with the MongoDb Java Driver authentication with FerretDb 0.9.0.
## 1 - install sdkman
This helps installing java!
```bash
$ curl -s "https://get.sdkman.io" | bash
```
## 2 - install java 17
```bash
$ java install java 17.0.6-tem
```
## 3 - start FerretDb
```bash
$ docker compose up
```
## 4 - Run the test
```bash
$ ./mvnw clean test
```
## Error with MongoDatabase.createCollection()
`MongoDatabase.createCollection()` fails with following message (even if not creating a _capped_ collection)
```
Command failed with error 238 (NotImplemented): 'create: support for field "capped" is not implemented yet' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "create: support for field \"capped\" is not implemented yet", "code": 238, "codeName": "NotImplemented"}
```
## Error with authentication (FIXED)
The error comes from `SaslAuthenticator` class of the java driver that tries to get the `conversationId` (a BsonInt32) from the Sasl response but does not find it!:
```
com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=PLAIN, userName='username', source='$external', password=, mechanismProperties=}
....
Caused by: org.bson.BsonInvalidOperationException: Document does not contain key conversationId
```