2023-11-20 16:32:23 -05:00
|
|
|
|
using Duende.IdentityServer;
|
|
|
|
|
|
using Duende.IdentityServer.Extensions;
|
|
|
|
|
|
using Duende.IdentityServer.Models;
|
|
|
|
|
|
using Duende.IdentityServer.Services;
|
|
|
|
|
|
using Duende.IdentityServer.Stores;
|
|
|
|
|
|
using Duende.IdentityServer.Stores.Serialization;
|
2020-07-16 08:01:39 -04:00
|
|
|
|
|
2022-09-27 18:30:37 +02:00
|
|
|
|
namespace Bit.Identity.IdentityServer;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2020-07-16 08:01:39 -04:00
|
|
|
|
public class AuthorizationCodeStore : DefaultGrantStore<AuthorizationCode>, IAuthorizationCodeStore
|
|
|
|
|
|
{
|
2020-07-30 17:00:13 -04:00
|
|
|
|
public AuthorizationCodeStore(
|
|
|
|
|
|
IPersistedGrantStore store,
|
2020-07-16 08:01:39 -04:00
|
|
|
|
IPersistentGrantSerializer serializer,
|
|
|
|
|
|
IHandleGenerationService handleGenerationService,
|
2020-07-30 17:00:13 -04:00
|
|
|
|
ILogger<DefaultAuthorizationCodeStore> logger)
|
|
|
|
|
|
: base(IdentityServerConstants.PersistedGrantTypes.AuthorizationCode, store, serializer,
|
|
|
|
|
|
handleGenerationService, logger)
|
2020-07-16 08:01:39 -04:00
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
public Task<string> StoreAuthorizationCodeAsync(AuthorizationCode code)
|
|
|
|
|
|
{
|
|
|
|
|
|
return CreateItemAsync(code, code.ClientId, code.Subject.GetSubjectId(), code.SessionId,
|
|
|
|
|
|
code.Description, code.CreationTime, code.Lifetime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<AuthorizationCode> GetAuthorizationCodeAsync(string code)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2020-07-30 17:00:13 -04:00
|
|
|
|
return GetItemAsync(code);
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-16 08:01:39 -04:00
|
|
|
|
public Task RemoveAuthorizationCodeAsync(string code)
|
|
|
|
|
|
{
|
|
|
|
|
|
// return RemoveItemAsync(code);
|
|
|
|
|
|
|
|
|
|
|
|
// We don't want to delete authorization codes during validation.
|
|
|
|
|
|
// We'll rely on the authorization code lifecycle for short term validation and the
|
|
|
|
|
|
// DatabaseExpiredGrantsJob to clean up old authorization codes.
|
|
|
|
|
|
return Task.FromResult(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|