IdentityServer4.Contrib.DynamoDB 1.0.0

Additional Details

Identity Server 4 has reached end of life

dotnet add package IdentityServer4.Contrib.DynamoDB --version 1.0.0                
NuGet\Install-Package IdentityServer4.Contrib.DynamoDB -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IdentityServer4.Contrib.DynamoDB" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IdentityServer4.Contrib.DynamoDB --version 1.0.0                
#r "nuget: IdentityServer4.Contrib.DynamoDB, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IdentityServer4.Contrib.DynamoDB as a Cake Addin
#addin nuget:?package=IdentityServer4.Contrib.DynamoDB&version=1.0.0

// Install IdentityServer4.Contrib.DynamoDB as a Cake Tool
#tool nuget:?package=IdentityServer4.Contrib.DynamoDB&version=1.0.0                

tests

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 2,229 9/17/2020
1.0.0-beta3 483 9/2/2020
1.0.0-beta2 337 9/2/2020
1.0.0-beta1 333 9/1/2020

Release