Browse Source

fix: register MongoDB AWS authentication for Atlas IAM (driver 3.x) (#1324)

MongoDB.Driver 3.x moved MONGODB-AWS into MongoDB.Driver.Authentication.AWS
and requires explicit registration. Without it, Atlas IAM connection strings
fail at startup with "Unable to create an authenticator".

Co-authored-by: Cursor <cursoragent@cursor.com>
master
Sina Darbouy 3 weeks ago
committed by GitHub
parent
commit
9dbc5ede75
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      backend/src/Squidex.Data.MongoDb/MongoClientFactory.cs
  2. 1
      backend/src/Squidex.Data.MongoDb/Squidex.Data.MongoDb.csproj

8
backend/src/Squidex.Data.MongoDb/MongoClientFactory.cs

@ -8,6 +8,7 @@
using System.Text.Json;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Authentication.AWS;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Entities;
using Squidex.Domain.Apps.Entities.Assets;
@ -23,6 +24,8 @@ namespace Squidex;
public static class MongoClientFactory
{
private static int awsAuthenticationRegistered;
public static void SetupSerializer(JsonSerializerOptions jsonSerializerOptions, BsonType representation)
{
// Register the serializers first.
@ -53,6 +56,11 @@ public static class MongoClientFactory
public static MongoClient Create(string? connectionString, Action<MongoClientSettings>? configure = null)
{
if (Interlocked.Exchange(ref awsAuthenticationRegistered, 1) == 0)
{
MongoClientSettings.Extensions.AddAWSAuthentication();
}
var clientSettings = MongoClientSettings.FromConnectionString(connectionString);
// If we really need custom config.

1
backend/src/Squidex.Data.MongoDb/Squidex.Data.MongoDb.csproj

@ -21,6 +21,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MongoDB.Driver" Version="3.8.0" />
<PackageReference Include="MongoDB.Driver.Authentication.AWS" Version="3.8.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="3.0.0" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.3.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />

Loading…
Cancel
Save