Class ReadableUserCodeGenerator
- Namespace
- Fdyay.IdentityServer.Services
- Assembly
- Fdyay.IdentityServer.Core.dll
Twelve characters from an alphabet without the ones misread off a screen: this server's default.
public sealed class ReadableUserCodeGenerator : IUserCodeGenerator
- Inheritance
-
ReadableUserCodeGenerator
- Implements
- Inherited Members
Remarks
The alphabet omits characters that are read wrong off a screen and typed wrong into a phone — no O or 0, no I, L or 1, no U against V. A user code is entered by hand from across a room, so an alphabet that is merely large costs more in mistyped codes than it buys in entropy.
Twelve characters from a 20 character alphabet is a little over 51 bits, which matters because the code names a
pending authorization to anyone who guesses it. Throttling the polling endpoint is not enough on its own: the
user code is entered on a different surface, so it must be hard to guess in its own right. Until 0.83.0 this was
NumericUserCodeService, a name it never deserved; NumericUserCodeGenerator is the numeric one.
Properties
RetryLimit
How many codes may be tried for one device before giving up on finding an unused one.
public int RetryLimit { get; }
Property Value
Remarks
UserCodeType
The name a client or DeviceFlowOptions.DefaultUserCodeType selects this generator by.
public string UserCodeType { get; }
Property Value
Remarks
Methods
GenerateAsync(CancellationToken)
A new user code of this generator's type. Whether it is already in use is the caller's to check.
public Task<string> GenerateAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels the generation.