Class ApiKeyRecord

Assembly: redb.Tsak.Core.dll

Represents a stored API key with associated metadata.
The stores HMAC-SHA256(key) — the raw key is NEVER persisted.

public sealed record ApiKeyRecord : IEquatable<ApiKeyRecord>

Inheritance

Object→ApiKeyRecord

Implements

Properties

CreatedAt

When the key was created.

public DateTimeOffset CreatedAt { get; init; }

ExpiresAt

Optional expiration. Null = never expires.

public DateTimeOffset? ExpiresAt { get; init; }

Id

Unique identifier for this key (for revocation / listing).

public required string Id { get; init; }

IsValid

Checks if the key is currently valid (not expired, not revoked).

public bool IsValid { get; }

KeyHash

HMAC-SHA256 hash of the API key. Raw key is never stored.

public required string KeyHash { get; init; }

Name

Display name for this key (e.g., "ci-deploy", "admin-portal").

public string Name { get; init; }

Revoked

Whether this key has been revoked.

public bool Revoked { get; init; }

Roles

Comma-separated roles (e.g., "admin", "reader", "operator").

public string Roles { get; init; }

UserId

User ID the key belongs to (nullable in standalone mode).

public string? UserId { get; init; }

Methods

GetRoles()

Parsed role set for authorization checks.

public IReadOnlySet<string> GetRoles()