Table of Contents

Class SystemApiKeyManagementService

Namespace
Tharga.Team.Service
Assembly
Tharga.Team.Service.dll

Delegates system API key operations to IApiKeyAdministrationService, stamping the creating user's identity from their claims rather than trusting a caller-supplied value.

public class SystemApiKeyManagementService : ISystemApiKeyManagementService
Inheritance
SystemApiKeyManagementService
Implements
Inherited Members

Remarks

Split out of ApiKeyManagementService: these operations belong to no team, so they carry no per-team owner-scoping and are registered as a system service. Keeping them alongside the team operations is what previously let one authorization policy be applied to both.

Constructors

SystemApiKeyManagementService(IApiKeyAdministrationService, IHttpContextAccessor)

public SystemApiKeyManagementService(IApiKeyAdministrationService inner, IHttpContextAccessor httpContextAccessor = null)

Parameters

inner IApiKeyAdministrationService
httpContextAccessor IHttpContextAccessor

Methods

CreateSystemKeyAsync(string, string[], DateTime?)

public Task<IApiKey> CreateSystemKeyAsync(string name, string[] scopes, DateTime? expiryDate = null)

Parameters

name string
scopes string[]
expiryDate DateTime?

Returns

Task<IApiKey>

DeleteSystemKeyAsync(string)

public Task DeleteSystemKeyAsync(string key)

Parameters

key string

Returns

Task

GetSystemKeysAsync()

public IAsyncEnumerable<IApiKey> GetSystemKeysAsync()

Returns

IAsyncEnumerable<IApiKey>

LockSystemKeyAsync(string)

public Task LockSystemKeyAsync(string key)

Parameters

key string

Returns

Task

RefreshSystemKeyAsync(string)

public Task<IApiKey> RefreshSystemKeyAsync(string key)

Parameters

key string

Returns

Task<IApiKey>

SetSystemKeyDisabledAsync(string, bool)

Disables the key, or enables it again. A disabled key is refused at authentication but keeps its name, scopes, roles, tags and history — the reversible alternative to DeleteKeyAsync(string, string).

public Task SetSystemKeyDisabledAsync(string key, bool disabled)

Parameters

key string
disabled bool

Returns

Task

Remarks

Refreshing a disabled key does not enable it. A refresh mints a new secret; it is not a decision to trust the key again, and the usual reason to refresh is the same suspected leak that prompted the disable.