Class RedbApiKeyStore
Redb-backed API key store. Persists keys across restarts and cluster nodes.
The hash lives in ValueUnique — one record per key is enforced by the database
(concurrent seeding on several nodes cannot duplicate), and the lookup on every request
is a single probe of the unique index. Props.Id carries its own
[RedbUnique] key, so revocation resolves the record by one indexed probe too;
rotating a key's secret in config (same id, new hash) updates the id's record in place.
value_string still mirrors the hash for compatibility.
public sealed class RedbApiKeyStore : IApiKeyStore
Inheritance
Implements
Methods
GetAllAsync(CancellationToken)
Get all key records (for admin listing).
public Task<IReadOnlyList<ApiKeyRecord>> GetAllAsync(CancellationToken ct = default)
GetByHashAsync(string, CancellationToken)
Find a key record by its hash. Returns null if not found.
public Task<ApiKeyRecord?> GetByHashAsync(string keyHash, CancellationToken ct = default)
RevokeAsync(string, CancellationToken)
Revoke a key by its Id.
public Task<bool> RevokeAsync(string id, CancellationToken ct = default)
SaveAsync(ApiKeyRecord, CancellationToken)
Save (insert or update) a key record.
public Task SaveAsync(ApiKeyRecord record, CancellationToken ct = default)