Table of Contents

Interface IGrantStore

Namespace
Excalibur.A3.Authorization
Assembly
Excalibur.A3.Abstractions.dll

Provider-neutral store for authorization grant persistence.

public interface IGrantStore : IServiceProvider
Inherited Members

Remarks

Follows the Microsoft ASP.NET Core Identity IUserStore<TUser> pattern: minimal CRUD surface (5 methods) with GetService(Type) for ISP extensions.

Replaces both the internal IGrantRequestProvider (11-method, SQL-coupled) and the abstractions-level IGrantRequestProvider (5 methods + GetService).

Optional capabilities — including durability, discovered via IDurableGrantStore — are resolved through GetService(Type), never by casting the store. A store answers for the capabilities it provides; decorators MUST forward GetService to the wrapped store.

Methods

DeleteGrantAsync(string, string, string, string, string?, DateTimeOffset?, CancellationToken)

Deletes a grant with optional revocation metadata.

Task<int> DeleteGrantAsync(string userId, string tenantId, string grantType, string qualifier, string? revokedBy, DateTimeOffset? revokedOn, CancellationToken cancellationToken)

Parameters

userId string

The user/subject identifier.

tenantId string

The tenant identifier.

grantType string

The grant type.

qualifier string

The qualifier/scope.

revokedBy string

Optional actor identifier who revoked the grant.

revokedOn DateTimeOffset?

Optional revocation timestamp (UTC).

cancellationToken CancellationToken

Cancellation token.

Returns

Task<int>

Number of rows affected.

GetAllGrantsAsync(string, bool, CancellationToken)

Retrieves all grants for a user, optionally including expired grants.

Task<IReadOnlyList<Grant>> GetAllGrantsAsync(string userId, bool includeExpired, CancellationToken cancellationToken)

Parameters

userId string

The user/subject identifier.

includeExpired bool

true to include expired grants; false to return only active (non-expired) grants. Authorization and SoD decision paths MUST pass false.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<Grant>>

All grants for the specified user, filtered per includeExpired.

GetAllGrantsAsync(string, CancellationToken)

Retrieves all active (non-expired) grants for a user.

Task<IReadOnlyList<Grant>> GetAllGrantsAsync(string userId, CancellationToken cancellationToken)

Parameters

userId string

The user/subject identifier.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<Grant>>

All non-expired grants for the specified user.

Remarks

This overload is default-secure: expired grants are excluded so they can never influence an authorization or separation-of-duties decision (Microsoft soft-delete-filter pattern). Callers that legitimately need expired grants (reporting, orphaned-access detection, reconciliation) MUST use the GetAllGrantsAsync(string, bool, CancellationToken) overload with includeExpired: true.

GetGrantAsync(string, string, string, string, CancellationToken)

Retrieves a specific grant.

Task<Grant?> GetGrantAsync(string userId, string tenantId, string grantType, string qualifier, CancellationToken cancellationToken)

Parameters

userId string

The user/subject identifier.

tenantId string

The tenant identifier.

grantType string

The grant type.

qualifier string

The qualifier/scope.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Grant>

The grant, or null if not found.

GrantExistsAsync(string, string, string, string, CancellationToken)

Checks whether a specific grant exists.

Task<bool> GrantExistsAsync(string userId, string tenantId, string grantType, string qualifier, CancellationToken cancellationToken)

Parameters

userId string

The user/subject identifier.

tenantId string

The tenant identifier.

grantType string

The grant type.

qualifier string

The qualifier/scope.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<bool>

true if the grant exists; otherwise false.

SaveGrantAsync(Grant, CancellationToken)

Saves or updates a grant (upsert).

Task<int> SaveGrantAsync(Grant grant, CancellationToken cancellationToken)

Parameters

grant Grant

The grant to persist.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<int>

Number of rows affected.