Class TokenOptions
- Namespace
- Codebelt.SharedKernel
- Assembly
- Codebelt.SharedKernel.dll
Configuration options for Token.
public class TokenOptions : IParameterObject
- Inheritance
-
objectTokenOptions
- Implements
Examples
The following example loosens the Token validation rules so a developer-supplied 20-character string can be accepted as a token during local testing. Use TokenOptions whenever a Token consumer has constraints that differ from the default 32-128 character window or the 4-distinct-character minimum.
using Codebelt.SharedKernel;
namespace DeveloperEnvironmentSample;
public static class TestTokenFactory
{
public static Token CreateDevelopmentToken(string candidate)
{
var options = new TokenOptions
{
MinimumLength = 16,
MaximumLength = 64,
MaximumCharacterFrequency = 0
};
// The TokenOptions delegate wires the relaxed policy into the constructor.
return new Token(candidate, o =>
{
o.MinimumLength = options.MinimumLength;
o.MaximumLength = options.MaximumLength;
o.MaximumCharacterFrequency = options.MaximumCharacterFrequency;
});
}
}
Constructors
TokenOptions()
Initializes a new instance of the TokenOptions class.
public TokenOptions()
Remarks
The following table shows the initial property values for an instance of TokenOptions.
| Property | Initial Value |
|---|---|
| MinimumLength | 32 |
| MaximumLength | 128 |
| MaximumCharacterFrequency | 4 |
Properties
MaximumCharacterFrequency
Gets or sets the maximum character frequency of the Token.
public byte MaximumCharacterFrequency { get; set; }
Property Value
Remarks
In the event that MaximumCharacterFrequency is greater than the MinimumLength, it will be set to the MinimumLength.
MaximumLength
Gets or sets the maximum length of the Token.
public byte MaximumLength { get; set; }
Property Value
MinimumLength
Gets or sets the minimum length of the Token.
public byte MinimumLength { get; set; }