Skip to content

Commit

Permalink
Upgrade to the latest version of the driver, adding support for the s…
Browse files Browse the repository at this point in the history
…election of the server API version
  • Loading branch information
tsutomi committed Apr 3, 2022
1 parent f24f9d7 commit b6be996
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Deveel.Identity.MongoDb/Deveel.Identity.MongoDb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<PackageLicenseExpression> Apache-2.0</PackageLicenseExpression>
<PackageIcon>deveel-logo.png</PackageIcon>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<AssemblyVersion>1.0.2.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -34,7 +34,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.14" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
<PackageReference Include="MongoDB.Driver" Version="2.15.0" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions src/Deveel.Identity.MongoDb/Security/MongoDbOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ public class MongoDbOptions {
public string RolesCollection { get; set; } = "roles";

public string UsersCollection { get; set; } = "users";

public bool UseServerApiV1 { get; set; } = false;
}
}
7 changes: 6 additions & 1 deletion src/Deveel.Identity.MongoDb/Security/MongoDbStoreBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ protected MongoDbStoreBase(MongoDbStoreOptions options)
if (String.IsNullOrWhiteSpace(Options.ConnectionString))
throw new MongoConfigurationException("The connection string was not set");

return new MongoClient(Options.ConnectionString);
var settings = MongoClientSettings.FromConnectionString(Options.ConnectionString);

if (Options.UseServerApiV1)
settings.ServerApi = new ServerApi(ServerApiVersion.V1);

return new MongoClient(settings);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class MongoDbStoreOptions : MongoDbOptions {
DatabaseName = options.DatabaseName;
RolesCollection = options.RolesCollection;
UsersCollection = options.UsersCollection;
UseServerApiV1 = options.UseServerApiV1;
}

public string TenantId { get; set; }
Expand Down

0 comments on commit b6be996

Please sign in to comment.