Table of Contents

Interface IHandleGenerationService

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

Mints the opaque handles this server hands out.

public interface IHandleGenerationService

Remarks

Authorization codes, reference tokens, refresh tokens, refresh-token family ids, device codes and server-side session keys are all the same thing: a value with no meaning except that holding it proves you were given it. They were seven calls to one static method, which is a fine implementation and no seam at all — a host needing a different length, a different alphabet, or entropy from somewhere other than the process had nothing to replace.

One interface for all of them rather than one per handle kind. They differ in what they unlock, not in what makes them safe, and a host that wants longer handles wants longer handles.

Methods

GenerateAsync(CancellationToken)

A new handle.

Task<string> GenerateAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<string>

GenerateAsync(CancellationToken, int)

A new handle from length bytes of entropy.

[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Duende's order, which a host moving off Duende compiles against.")]
Task<string> GenerateAsync(CancellationToken cancellationToken, int length)

Parameters

cancellationToken CancellationToken
length int

Returns

Task<string>

Remarks

Duende 8.0.1's GenerateAsync(ct, length = 32), as an overload: changing the method above would break every host's generator. This server's own callers still ask the method above, as Duende's three pass 32. A default interface method, so a host's generator written before 0.158.0 keeps compiling; one that does not implement it throws NotSupportedException when asked, rather than ignoring the length.