Skip to content

IDapperMaticKeyRepository ​

Namespace: MJCZone.DapperMatic.AspNetCore.Repositories

Assembly: MJCZone.DapperMatic.AspNetCore

Summary ​

Keeps API keys: their secrets only as hashes. Keys are looked up one at a time, by id, as requests sign in, so they are kept apart from the policies and tenants (which every instance reads whole): in memory, in a file, or in a database table.

abstract public

Note: This is an interface that defines a contract. Look for implementing classes in the same or related namespaces.

Contents ​

Methods (5)

Methods ​

GetAsync ​

Reads a key.

csharp
Task<DapperMaticApiKey?> GetAsync(
    string id,
    CancellationToken cancellationToken)

Parameters ​

  • id (string) - The key's id.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<DapperMaticApiKey?>

The key, or null if none has that id.

ListAsync ​

Lists keys, revoked ones among them.

csharp
Task&lt;IReadOnlyList&lt;DapperMaticApiKey&gt;&gt; ListAsync(
    DapperMaticKeyFilter filter,
    CancellationToken cancellationToken)

Parameters ​

  • filter (DapperMaticKeyFilter) - Which keys.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<IReadOnlyList<DapperMaticApiKey>>

The keys, newest first.

SaveAsync ​

Adds a key, or replaces the one of the same id.

csharp
Task SaveAsync(DapperMaticApiKey key, CancellationToken cancellationToken)

Parameters ​

  • key (DapperMaticApiKey) - The key.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task

A task.

RevokeAsync ​

Revokes a key: it no longer signs in; it is still listed.

csharp
Task&lt;bool&gt; RevokeAsync(
    string id,
    DateTimeOffset at,
    CancellationToken cancellationToken)

Parameters ​

  • id (string) - The key's id.
  • at (DateTimeOffset) - When.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;bool&gt;

True if the key was live.

TouchAsync ​

Records when keys were last used.

csharp
Task TouchAsync(string used, DateTimeOffset} cancellationToken)

Parameters ​

  • used (string) - When each key was last used, by id.
  • cancellationToken (DateTimeOffset}) - The cancellation token.

Returns ​

Type: Task

A task.