IdentityServer4.Contrib.DynamoDB
1.0.0-beta3
dotnet add package IdentityServer4.Contrib.DynamoDB --version 1.0.0-beta3
NuGet\Install-Package IdentityServer4.Contrib.DynamoDB -Version 1.0.0-beta3
<PackageReference Include="IdentityServer4.Contrib.DynamoDB" Version="1.0.0-beta3" />
paket add IdentityServer4.Contrib.DynamoDB --version 1.0.0-beta3
#r "nuget: IdentityServer4.Contrib.DynamoDB, 1.0.0-beta3"
// Install IdentityServer4.Contrib.DynamoDB as a Cake Addin #addin nuget:?package=IdentityServer4.Contrib.DynamoDB&version=1.0.0-beta3&prerelease // Install IdentityServer4.Contrib.DynamoDB as a Cake Tool #tool nuget:?package=IdentityServer4.Contrib.DynamoDB&version=1.0.0-beta3&prerelease
IdentityServer4.Contrib.DynamoDB
IdentityServer4.Contrib.DynamoDB is a persistence layer using AWS DynamoDB for operational data capability for Identity Server 4. Specifically, this store provides implementation for IPersistedGrantStore.
How to use
You need to install the nuget package
then you can inject the operational store in the Identity Server 4 Configuration at startup:
public void ConfigureServices(IServiceCollection services)
{
services.AddAWSService<IAmazonDynamoDB>();
...
services.AddIdentityServer()
...
.AddOperationalStore(options =>
{
options.DynamoDBContextConfig = new DynamoDBContextConfig
{
TableNamePrefix = "Dev_",
SkipVersionCheck = true,
ConsistentRead = true,
IgnoreNullValues = true
...
};
})
...
}
the solution approach
the solution was approached based on how the SQL Store storing the operational data, but the concept of DynamoDB as a NoSQL db is totally different than relational db concepts, all the operational data stores implement the following IPersistedGrantStore interface:
public interface IPersistedGrantStore
{
Task StoreAsync(PersistedGrant grant);
Task<PersistedGrant> GetAsync(string key);
Task<IEnumerable<PersistedGrant>> GetAllAsync(PersistedGrantFilter filter);
Task RemoveAsync(string key);
Task RemoveAllAsync(PersistedGrantFilter filter);
}
with the IPersistedGrantStore contract, we notice that the GetAllAsync(filter)
, RemoveAllAsync(filter)
defines a contract to read or remove all the grants in the store based on subject id, client ids and/or session ids and type of the grant, this is done in DynamoDB using the expensive Scan
operation, if you are not happy with this implementation, you can override the implementation of GetAllAsync
and RemoveAllAsync
and use Query
operation given that you already defined the right Indexes on DynamoDB table.
since DynamoDB has a Document Expiration feature based on a defined date time or time span, and to not implement a logic similar to SQL store implementation for cleaning up the store periodically from dangling grants, the store uses the ttl of DynamoDB while storing entries by setting Expiration
value as linux epoch value.
Note: setting the
Expiration
without explicitly enabling Ttl on DynamoDB table will not expire the documents.
Feedback
feedbacks are always welcomed, please open an issue for any problem or bug found, and the suggestions are also welcomed.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- AWSSDK.DynamoDBv2 (>= 3.3.106.36)
- IdentityServer4 (>= 4.0.0)
- IdentityServer4.Storage (>= 4.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0-beta3 | 489 | 9/2/2020 |
1.0.0-beta2 | 341 | 9/2/2020 |
1.0.0-beta1 | 341 | 9/1/2020 |
add logging for PersistedGrantStore