#2 Re: mORMot 2 » Authentication error with MongoDB 8.1/8.2 » 2025-11-04 09:51:33

ab wrote:

My concern about SCRAM-SHA-256 is that we would need to re-create the user with server-side password digest.
https://gist.github.com/synopse/5a3ea82 … 1f3da583c6

If the user was created without SCRAM-SHA-256 then it needs to be recreated to use it. But if we use saslSupportedMechs in hello it should be possible to automatically choose the highest available (and supported) mechanism for the user. Or just let the user choose the authentication mechanism like MongoDB Compass does.

#3 Re: mORMot 2 » Authentication error with MongoDB 8.1/8.2 » 2025-11-04 09:25:50

As a temporary quick workaround I'm currently setting FServerBuildInfoNumber to 8010000 before Auth and moved AfterOpen after Auth. (Of course, this only works because we don't need support for those really old versions.)

I think the best approach would be to separate buildinfo from AfterOpen. In TMongoClient.Open we could call it before or after AfterOpen but in TMongoClient.OpenAuth it must be called after Auth.

Using saslSupportedMechs in hello seems to be the best way to determine the correct mechanics but it seems to need DatabaseName und UserName to be passed.

And support for SCRAM-SHA-256 would be great as it is the default since version 4.0 and admins may tend to disable SCRAM-SHA-1.

#4 mORMot 2 » Authentication error with MongoDB 8.1/8.2 » 2025-11-03 17:39:39

Bjoern Henke
Replies: 7

With newer MongoDB versions the authentication fails.

Reason is the following:
Any application that runs the buildInfo command before authenticating is incompatible with MongoDB 8.1.
(https://www.mongodb.com/docs/manual/rel … atibility/)

mORMot calls buildinfo in TMongoClient.AfterOpen before TMongoClient.Auth because Auth needs the correct ServerBuildInfoNumber.

My current idea is to set fServerBuildInfoNumber to at least 8010000 if buildinfo fails with {"ok":0,"errmsg":"Command buildInfo requires authentication","code":13,"codeName":"Unauthorized"}.
Or simply give TMongoClient.Auth an option to force SCRAM-SHA-1 (like ForceMongoDBCR, but with contrary effect).

#5 mORMot 2 » Strings not stored as they are if they look like ISO 8601 » 2023-07-20 13:39:29

Bjoern Henke
Replies: 1

The TBsonWriter writes strings as a double value if they look like an ISO 8601. When I get them back from the database, I don't get the original string.

Currently, the only option to fix this, seems to be to remove "Iso8601CheckAndDecode(value, valueLen, dt) or" from TBsonWriter.BsonWriteUtf8OrDecode.
The two "MAGIC" conditions should be fine but checking every string for ISO 8601 and forcing them into datetime can change the string unintentionally.

#6 Re: mORMot 1 » mORMot2: Loosing binary data somewhere in conversion » 2022-12-15 16:55:28

The code above is just an example to reproduce the problem.

I'm basically searching for a way to convert mongo JSON back to a variant. Mainly the opposite of VariantSaveMongoJson.

The best I found so far was the combination of Bson and BsonDocumentToDoc which seemed to be working except the loss of the binary data.

#7 Re: mORMot 1 » mORMot2: Loosing binary data somewhere in conversion » 2022-12-12 16:00:09

GetValueOrNull calls SetVariantByValue which then does TSynInvokeableVariantType.CopyByValue.
The variant type is DocVariantType (274) instead of BsonVariantType (275) needed by ToBlob.

I already tried GetVarData instead of GetValueOrNull but the result remains the same.

I couldn't yet find a way to convert a DocVariantType into a BsonVariantType and I'm wondering how TRestStorageMongoDB.RetrieveBlobFields accomplishes this.

#8 mORMot 1 » mORMot2: Loosing binary data somewhere in conversion » 2022-12-07 16:36:29

Bjoern Henke
Replies: 4

I've some binary data stored as RawByteString and convert it to MongoJson. When converting back from JSON to RawByteString the binary data gets lost.

Example code:

var
  BV,V: Variant;
  JSON: String;
  RBS : RawByteString;
begin
  TDocVariant.New(V);
  RBS:=#1#2#3;
  BsonVariantType.FromBinary(RBS,bbtGeneric,BV);
  TDocVariantData(V).AddValue('Test',BV);
  JSON:=VariantSaveMongoJson(V,modMongoStrict);
  V:=BsonDocumentToDoc(Bson(JSON));
  BV:=TDocVariantData(V).GetValueOrNull('Test');
  if not VarIsNull(BV) 
    then Result:=BsonVariantType.ToBlob(BV,RBS);
end;

BsonVariantType.ToBlob returns false because it expects another variant type.

#9 mORMot 1 » ExportServerNamedPipe and TSQLRestClientURINamedPipe in mORMot2 » 2022-11-29 15:57:26

Bjoern Henke
Replies: 3

I'm currently trying to convert some code from an ex-colleague to mORMot2.
This code uses ExportServerNamedPipe and TSQLRestClientURINamedPipe for whose I can't find something similar in mORMot2.
(I only found some comments in the mORMot2 code mentioning some NamedPipe things that don't seem to exist either.)

What should I use in mORMot2 instead of ExportServerNamedPipe and TSQLRestClientURINamedPipe?

Board footer

Powered by FluxBB