Introduction
OpenIddict is a free and open source OIDC framework for .NET. that can be used to create both OIDC Clients and Authorization Server.
OpenIddict is a flexible framework for developing a Single Sign-On OpenID Connect (OIDC) Authorization Server. For an application to trust tokens issued by the OIDC Authorization server (issuer) the tokens needs to be signed by the issuer (typically using public/private keys).
Why Key Rotation Is Essential
If an attacker were able to create their own tokens, then this would allow them unauthorized access. For an attacker to do this, they would need access to the private key.
Therefore securing the key is very important, however it is possible for an attacker to derive the key if they can observe enough signed tokens, and have sufficient period of time for them to run the compute necessary to derive the private key.
To mitigate this risk, keys should be changed every 60-90 days. Performing this task manually is a chore, and will possibly be missed. A better solution is for the OIDC Authorisation server to rotate the key every 60 days automatically.
Out of the box, OpenIddict does not offer automatic key rotation. In OpenIddict, key material must be configured via code, modifying the `OpenIddictServerOptions ' object. Signing credentials configured on the options object are passed to services to be displayed in the JWKs endpoint or used for signing. Changes to key material, therefore, require code changes and redeployment.
This is why Rock Solid Knowledge has built a Key Rotation component for OpenIddict. To add automatic key rotation to OpenIddict its as simple as adding the Rsk.OpenIddict.KeyRotation NuGet package to your .NET Core OpenIddict Server and call the extension on the OpenIddictServerBuilder, to enable this functionality.
How to Use
Using the RSK Key Rotation for the OpenIddict package is simple, and we will guide you through a simple installation now. Currently, RSK Key Rotation only supports using Entity Framework databases for key storage. So, the following will be configured to use a database.
If you already have an OpenIddict instance, you can follow these steps to add Key Rotation. Or alternatively, you can use our AdminUI integration sample and follow these steps.
Install the NuGet package in your OpenIddict server project.
dotnet add package Rsk.KeyRotation.OpenIddict
Call the . AddKeyRotation extension method on the OpenIddictServerBuilder