TokenOptions Class
Definition
- Namespace
- Codebelt.SharedKernel
- Assemblies
- 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
| Name | Description |
|---|---|
| TokenOptions() | Initializes a new instance of the TokenOptions class. |
Properties
| Name | Description |
|---|---|
| MaximumCharacterFrequency | Gets or sets the maximum character frequency of the Token. |
| MaximumLength | Gets or sets the maximum length of the Token. |
| MinimumLength | Gets or sets the minimum length of the Token. |