Repository navigation
fix: allow multiple algorthms to be configured for compatibility store #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jhbritton-RSK
wants to merge
4
commits into
main
Choose a base branch
from
bug/132-compatibility-key-store-configure-algrithms
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4021561
bug: only one legacy key registered from key management store. No abi…
jhbritton-RSK 38b63e4
feat: add propergation time setting to prioritise published keys in c…
jhbritton-RSK 1760c2d
docs: updated documentation for compatibility key store
jhbritton-RSK 6882a22
pr: correcting issues commented on in pull request review
jhbritton-RSK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...n.IdentityServer/src/Stores/Compatibility/IIdentityServerSigningCredentialStoreFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Copyright (c) 2026, Rock Solid Knowledge Ltd | ||
| // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
|
|
||
| namespace Open.IdentityServer.Stores; | ||
|
|
||
| /// <summary> | ||
| /// Interface for the creating signing credential store | ||
| /// </summary> | ||
| public interface IIdentityServerSigningCredentialStoreFactory | ||
| { | ||
| /// <summary> | ||
| /// Creates instance of <see cref="IdentityServerSigningCredentialStore"/> setting algorithm setting to provided alg property | ||
| /// </summary> | ||
| /// <param name="alg">algorithm of signing key to provide</param> | ||
| /// <returns></returns> | ||
| public IdentityServerSigningCredentialStore Create(string alg); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...en.IdentityServer/src/Stores/Compatibility/IdentityServerSigningCredentialStoreFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (c) 2026, Rock Solid Knowledge Ltd | ||
| // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
|
|
||
| using System; | ||
|
jhbritton-RSK marked this conversation as resolved.
Resolved
|
||
| using Microsoft.Extensions.Logging; | ||
| using Open.IdentityServer.Configuration; | ||
| using Open.IdentityServer.DataProtection; | ||
| using Open.IdentityServer.Services; | ||
|
|
||
| namespace Open.IdentityServer.Stores; | ||
|
|
||
| /// <summary> | ||
| /// Factory for the creating signing credential store | ||
| /// </summary> | ||
| /// <param name="identityServerKeyStore">The key store used to retrieve signing keys.</param> | ||
| /// <param name="dataProtectedIdentityServerKeyMaterialConverter">Converter used to decrypt and convert data-protected key material into usable credentials.</param> | ||
| /// <param name="timeProvider">Time provider implementation</param> | ||
| /// <param name="options">Compatibility key store options</param> | ||
| /// <param name="telemetry">The telemetry service</param> | ||
| /// <param name="logger">The logger</param> | ||
| public class IdentityServerSigningCredentialStoreFactory(IIdentityServerKeyStore identityServerKeyStore, | ||
| DataProtectedIdentityServerKeyMaterialConverter dataProtectedIdentityServerKeyMaterialConverter, | ||
| TimeProvider timeProvider, | ||
| CompatibilityKeyStoreOptions options, | ||
| ITelemetryService telemetry, | ||
| ILogger<IdentityServerSigningCredentialStore> logger): IIdentityServerSigningCredentialStoreFactory | ||
| { | ||
| /// <inheritdoc /> | ||
| public IdentityServerSigningCredentialStore Create(string alg) | ||
| { | ||
| return new IdentityServerSigningCredentialStore(identityServerKeyStore, dataProtectedIdentityServerKeyMaterialConverter, timeProvider, options, telemetry, logger) | ||
| { | ||
| Algorithm = alg | ||
| }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...entityServer.UnitTests/Configuration/DependencyInjection/BuilderExtensions/CryptoTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // Copyright (c) 2026, Rock Solid Knowledge Ltd | ||
| // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
|
|
||
| using System.Linq; | ||
| using AwesomeAssertions; | ||
|
jhbritton-RSK marked this conversation as resolved.
Resolved
|
||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.IdentityModel.Tokens; | ||
| using Open.IdentityServer.Configuration; | ||
| using Open.IdentityServer.DataProtection; | ||
| using Open.IdentityServer.Stores; | ||
| using Xunit; | ||
|
|
||
| namespace Open.IdentityServer.UnitTests.Configuration.DependencyInjection; | ||
|
|
||
| public class CryptoTests | ||
| { | ||
| private IServiceCollection serviceCollection = new ServiceCollection(); | ||
|
|
||
| [Fact] | ||
| public void AddCompatibilityKeyStores_WhenDefaultValues_ShouldRegisterCompatibilityStoreServices() | ||
| { | ||
| IIdentityServerBuilder builder = new IdentityServerBuilder(serviceCollection); | ||
|
|
||
| builder.AddCompatibilityKeyStores(); | ||
|
|
||
| serviceCollection.Should().ContainSingle(d => | ||
| d.ServiceType == typeof(CompatibilityKeyStoreOptions) && | ||
| d.Lifetime == ServiceLifetime.Singleton); | ||
|
|
||
| serviceCollection.Should().ContainSingle(d => | ||
| d.ImplementationType == typeof(DataProtectedIdentityServerKeyMaterialConverter) && | ||
| d.Lifetime == ServiceLifetime.Transient); | ||
|
|
||
| serviceCollection.Should().ContainSingle(d => | ||
| d.ServiceType == typeof(IValidationKeysStore) && | ||
| d.ImplementationType == typeof(IdentityServerValidationKeysStore) && | ||
| d.Lifetime == ServiceLifetime.Scoped); | ||
|
|
||
| serviceCollection.Should().ContainSingle(d => | ||
| d.ServiceType == typeof(IIdentityServerSigningCredentialStoreFactory) && | ||
| d.ImplementationType == typeof(IdentityServerSigningCredentialStoreFactory) && | ||
| d.Lifetime == ServiceLifetime.Singleton); | ||
|
|
||
| serviceCollection.Should().ContainSingle(d => | ||
| d.ServiceType == typeof(ISigningCredentialStore) && | ||
| d.Lifetime == ServiceLifetime.Scoped); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void AddCompatibilityKeyStores_WhenMultipleSupportedAlgorithms_ShouldRegisterISigningCredentialStoreForEachAlgorithm() | ||
| { | ||
| IIdentityServerBuilder builder = new IdentityServerBuilder(serviceCollection); | ||
|
|
||
| builder.AddCompatibilityKeyStores(cnf => | ||
| { | ||
| cnf.SupportedAlgorithms = | ||
| [SecurityAlgorithms.RsaSha256, SecurityAlgorithms.RsaSsaPssSha384, SecurityAlgorithms.EcdsaSha512]; | ||
| }); | ||
|
|
||
| serviceCollection.Should().ContainSingle(d => | ||
| d.ServiceType == typeof(CompatibilityKeyStoreOptions) && | ||
| d.Lifetime == ServiceLifetime.Singleton); | ||
|
|
||
| serviceCollection.Should().ContainSingle(d => | ||
| d.ImplementationType == typeof(DataProtectedIdentityServerKeyMaterialConverter) && | ||
| d.Lifetime == ServiceLifetime.Transient); | ||
|
|
||
| serviceCollection.Should().ContainSingle(d => | ||
| d.ServiceType == typeof(IValidationKeysStore) && | ||
| d.ImplementationType == typeof(IdentityServerValidationKeysStore) && | ||
| d.Lifetime == ServiceLifetime.Scoped); | ||
|
|
||
| serviceCollection.Should().ContainSingle(d => | ||
| d.ServiceType == typeof(IIdentityServerSigningCredentialStoreFactory) && | ||
| d.ImplementationType == typeof(IdentityServerSigningCredentialStoreFactory) && | ||
| d.Lifetime == ServiceLifetime.Singleton); | ||
|
|
||
| serviceCollection.Where(d => | ||
| d.ServiceType == typeof(ISigningCredentialStore) && | ||
| d.Lifetime == ServiceLifetime.Scoped).Should().HaveCount(3); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.