Skip to content

Commit

Permalink
fix: refresh keys page crash
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Apr 13, 2021
1 parent 6ce0269 commit a9ceab4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
28 changes: 28 additions & 0 deletions src/Aguacongas.TheIdServer/Services/KeyStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Project: Aguafrommars/TheIdServer
// Copyright (c) 2021 @Olivier Lefebvre
using Aguacongas.IdentityServer.Admin.Services;
using Aguacongas.IdentityServer.Store;
using Aguacongas.IdentityServer.Store.Entity;
using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Aguacongas.TheIdServer.Services
{
public class KeyStore<T1, T2> : IKeyStore<T1> where T2 : IAuthenticatedEncryptorDescriptor
{
private readonly KeyManagerWrapper<T2> _wrapper;

public KeyStore(KeyManagerWrapper<T2> wrapper)
{
_wrapper = wrapper ?? throw new ArgumentNullException(nameof(wrapper));
}

public Task<PageResponse<Key>> GetAllKeysAsync(CancellationToken cancellationToken = default)
=> Task.FromResult(_wrapper.GetAllKeys());

public Task RevokeKeyAsync(string id, string reason, CancellationToken cancellationToken = default)
=> throw new NotImplementedException();
}
}
7 changes: 3 additions & 4 deletions src/Aguacongas.TheIdServer/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Auth = Aguacongas.TheIdServer.Authentication;
using ConfigurationModel = Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel;
using RavenDbStore = Aguacongas.IdentityServer.RavenDb.Store;

namespace Aguacongas.TheIdServer
Expand Down Expand Up @@ -182,10 +183,8 @@ void configureOptions(IdentityServerOptions options)
.AddTransient<IReadOnlyLocalizedResourceStore, ReadOnlyLocalizedResourceStore>()
.AddTransient<IAccessTokenProvider, AccessTokenProvider>()
.AddTransient<Microsoft.JSInterop.IJSRuntime, JSRuntime>()
.AddTransient<IKeyStore<RsaEncryptorDescriptor>>(p => new KeyStore<RsaEncryptorDescriptor>(p.CreateApiHttpClient(p.GetRequiredService<IOptions<IdentityServerOptions>>().Value),
p.GetRequiredService<ILogger<KeyStore<RsaEncryptorDescriptor>>>()))
.AddTransient<IKeyStore<IAuthenticatedEncryptorDescriptor>>(p => new KeyStore<IAuthenticatedEncryptorDescriptor>(p.CreateApiHttpClient(p.GetRequiredService<IOptions<IdentityServerOptions>>().Value),
p.GetRequiredService<ILogger<KeyStore<IAuthenticatedEncryptorDescriptor>>>()))
.AddTransient<IKeyStore<RsaEncryptorDescriptor>, KeyStore<RsaEncryptorDescriptor, Aguacongas.IdentityServer.KeysRotation.RsaEncryptorDescriptor>>()
.AddTransient<IKeyStore<IAuthenticatedEncryptorDescriptor>, KeyStore<IAuthenticatedEncryptorDescriptor, ConfigurationModel.IAuthenticatedEncryptorDescriptor>>()
.AddAdminApplication(new Settings())
.AddDatabaseDeveloperPageExceptionFilter()
.AddRazorPages(options => options.Conventions.AuthorizeAreaFolder("Identity", "/Account"));
Expand Down

0 comments on commit a9ceab4

Please sign in to comment.