Table of Contents

AccessKeyOptions Class

Definition

Namespace
Codebelt.SharedKernel.Security
Assemblies
Codebelt.SharedKernel.dll
Source
src/Codebelt.SharedKernel/Security/AccessKeyOptions.cs

Provides options to be used with AccessKey>.

public class AccessKeyOptions : IValidatableParameterObject, IParameterObject
Inheritance
object
AccessKeyOptions
Implements

Examples

The following example constructs an AccessKeyOptions instance with a custom DesiredTolerance and a bounded validity window, then validates the configuration before it is consumed by an AccessKey constructor. Use AccessKeyOptions whenever the default CoordinatedUniversalTime.MinValue / MaxValue / 30-second tolerance is not appropriate for the issuing system.

using System;
using Codebelt.SharedKernel;
using Codebelt.SharedKernel.Security;

namespace KeyIssuanceSample;

public static class OptionsFactory
{
    public static AccessKeyOptions CreateHourlyOptions()
    {
        var now = DateTime.UtcNow;
        return new AccessKeyOptions
        {
            ValidFrom = new CoordinatedUniversalTime(now),
            Expires = new CoordinatedUniversalTime(now.AddHours(1)),
            DesiredTolerance = TimeSpan.FromMinutes(1)
        };
    }
}

Constructors

Name Description
AccessKeyOptions()

Initializes a new instance of the AccessKeyOptions class.

Properties

Name Description
DesiredTolerance

Gets or sets the desired tolerance for potential clock skew variations. Default is 30 seconds.

Expires

Gets or sets the expiry date and time of the access key. Default is MaxValue (e.g., no expiration).

ValidFrom

Gets or sets the date and time from which the access key is valid. Default is MinValue (e.g., always valid).

Methods

Name Description
ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

See Also