Table of Contents

Class DefaultAuthorizationCodeStore

Namespace
Fdyay.IdentityServer.Services
Assembly
Fdyay.IdentityServer.Core.dll

Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.

public sealed class DefaultAuthorizationCodeStore : IAuthorizationCodeStore
Inheritance
DefaultAuthorizationCodeStore
Implements
Inherited Members

Constructors

DefaultAuthorizationCodeStore(IPersistedGrantStore, TimeProvider, IHandleGenerationService)

A code store over store.

public DefaultAuthorizationCodeStore(IPersistedGrantStore store, TimeProvider time, IHandleGenerationService handles)

Parameters

store IPersistedGrantStore

The persisted grant store the codes are kept in, keyed by the handle's hash.

time TimeProvider

The clock a code's expiry is checked against.

handles IHandleGenerationService

What mints each code's handle.

Methods

GetAuthorizationCodeAsync(string, CancellationToken)

The authorization code a handle names, or null.

public Task<AuthorizationCode?> GetAuthorizationCodeAsync(string code, CancellationToken cancellationToken = default)

Parameters

code string

The handle the client presented.

cancellationToken CancellationToken

Cancels the read.

Returns

Task<AuthorizationCode>

The code, or null when none is stored under the handle or it has expired.

RemoveAuthorizationCodeAsync(string, CancellationToken)

Removes the authorization code a handle names, so it cannot be redeemed again.

public Task RemoveAuthorizationCodeAsync(string code, CancellationToken cancellationToken = default)

Parameters

code string

The handle the client presented.

cancellationToken CancellationToken

Cancels the removal.

Returns

Task

StoreAuthorizationCodeAsync(AuthorizationCode, CancellationToken)

Stores an authorization code and returns the handle the client is given for it.

public Task<string> StoreAuthorizationCodeAsync(AuthorizationCode code, CancellationToken cancellationToken = default)

Parameters

code AuthorizationCode

The code's contents.

cancellationToken CancellationToken

Cancels the write.

Returns

Task<string>

The handle — the code value the authorize response carries.

TryRemoveAuthorizationCodeAsync(string, CancellationToken)

Removes the authorization code a handle names, saying whether this call is the one that removed it.

public Task<bool> TryRemoveAuthorizationCodeAsync(string code, CancellationToken cancellationToken = default)

Parameters

code string

The handle the client presented.

cancellationToken CancellationToken

Cancels the removal.

Returns

Task<bool>

True when the code was there and this call removed it; false when it was already gone.

Remarks

What the token endpoint redeems a code by, so of two requests presenting one code at the same moment only one is answered with tokens (RFC 6749 §4.1.2: a code is used once). Ours (security), 0.176.0; Duende reads the code and then removes it. The default store takes it in one step through TryRemoveAsync(string, CancellationToken); this default, for a code store of a host's own written before 0.176.0, removes and answers true, as before.