Class ApiKeyDescriptor
- Namespace
- Stratara.Abstractions.ApiKeys
- Assembly
- Stratara.Abstractions.dll
The stored, non-secret description of an issued API key. The raw key itself is never persisted — only its hash — so a descriptor can be listed and audited freely.
[ExcludeFromCodeCoverage]
public sealed record ApiKeyDescriptor : IEquatable<ApiKeyDescriptor>
- Inheritance
-
ApiKeyDescriptor
- Implements
- Inherited Members
- Extension Methods
Remarks
Two kinds share this shape: machine keys (UserId is null) act
as their own principal — the key id is the actor — and carry tenant-scoped
Roles; personal access tokens (UserId set) act as the
bound user, whose own memberships and roles apply, so Roles is empty for them.
Constructors
ApiKeyDescriptor(Guid, Guid, Guid?, string, IReadOnlyCollection<string>, DateTimeOffset, DateTimeOffset?, DateTimeOffset?)
The stored, non-secret description of an issued API key. The raw key itself is never persisted — only its hash — so a descriptor can be listed and audited freely.
public ApiKeyDescriptor(Guid Id, Guid TenantId, Guid? UserId, string Name, IReadOnlyCollection<string> Roles, DateTimeOffset CreatedAt, DateTimeOffset? ExpiresAt = null, DateTimeOffset? RevokedAt = null)
Parameters
IdGuidThe key's stable identity (also the machine key's actor id).
TenantIdGuidThe tenant the key is bound to.
UserIdGuid?The bound user for personal access tokens;
nullfor machine keys.NamestringDisplay name for administration ("CI deploy key").
RolesIReadOnlyCollection<string>Tenant-scoped roles for machine keys; empty for personal access tokens.
CreatedAtDateTimeOffsetIssuance timestamp.
ExpiresAtDateTimeOffset?Optional expiry; the key stops validating once passed.
RevokedAtDateTimeOffset?Revocation timestamp; a revoked key never validates again.
Remarks
Two kinds share this shape: machine keys (UserId is null) act
as their own principal — the key id is the actor — and carry tenant-scoped
Roles; personal access tokens (UserId set) act as the
bound user, whose own memberships and roles apply, so Roles is empty for them.
Properties
CreatedAt
Issuance timestamp.
public DateTimeOffset CreatedAt { get; init; }
Property Value
ExpiresAt
Optional expiry; the key stops validating once passed.
public DateTimeOffset? ExpiresAt { get; init; }
Property Value
Id
The key's stable identity (also the machine key's actor id).
public Guid Id { get; init; }
Property Value
Name
Display name for administration ("CI deploy key").
public string Name { get; init; }
Property Value
RevokedAt
Revocation timestamp; a revoked key never validates again.
public DateTimeOffset? RevokedAt { get; init; }
Property Value
Roles
Tenant-scoped roles for machine keys; empty for personal access tokens.
public IReadOnlyCollection<string> Roles { get; init; }
Property Value
TenantId
The tenant the key is bound to.
public Guid TenantId { get; init; }
Property Value
UserId
The bound user for personal access tokens; null for machine keys.
public Guid? UserId { get; init; }
Property Value
- Guid?