TsgcWSAPIKeyManager › Methods

TsgcWSAPIKeyManager Methods

Public methods grouped by purpose, followed by the full alphabetical list.

Issuance

NameDescription
IssueKeyGenerates, hashes and stores a new key; returns the plaintext (only time it can be observed).
RotateKeyIssues a fresh key for the same owner and scopes and marks the old one kksRotated.
RenewKeyExtends the key's expiration by the given number of seconds from now.

Validation

NameDescription
ValidateKeyValidates a raw key and optionally enforces a required scope and records the requester's IP.
IsRequestAuthorizedOne-shot authorization check: extracts the key from headers or query string and validates it.
IsExpiredReturns True if the key is past its expiry.
IsRevokedReturns True if the key is revoked.
KeyExistsReturns True if the key is known (active, revoked, expired or rotated).
CountReturns the number of keys currently stored.

Revocation

NameDescription
RevokeKeyMarks a key as revoked; subsequent ValidateKey calls return False.
PurgeExpiredRemoves all keys whose ExpiresAt is in the past.

Scopes

NameDescription
GrantScopeAdds a scope to an existing key.
RevokeScopeRemoves a scope from an existing key.
HasScopeReturns True if the key carries the given scope.
ListScopesReturns the scopes attached to a key.

Header parsing

NameDescription
ExtractKeyFromHeadersParses the Validation.HeaderName value out of a raw HTTP header block.
ExtractKeyFromQueryParses the Validation.QueryParamName value out of a raw query string.

Integration

NameDescription
IsConnectionAllowedServer hook enforcing the optional IPAllowlist when FailClosed is True.
IsMessageAllowedServer hook called for every inbound message; IP-level no-op by default.
RegisterConnectionTracks a new connection. Called automatically by the server.
UnregisterConnectionReleases tracking for a connection. Called automatically on disconnect.

Persistence

NameDescription
SaveToFilePersists keys and audit log to the given file (falls back to Storage.FileName when empty).
LoadFromFileRestores keys and audit log from file.
ExportKeysStream-based export of keys and audit log.
ImportKeysStream-based import of keys and audit log.

Audit

NameDescription
ClearAuditLogClears the audit log for a specific key or (when empty) for all keys.

All Methods (alphabetical)

NameDescription
ClearAuditLogClears the audit log for a specific key or (when empty) for all keys.
CountReturns the number of keys currently stored.
ExportKeysStream-based export of keys and audit log.
ExtractKeyFromHeadersParses the Validation.HeaderName value out of a raw HTTP header block.
ExtractKeyFromQueryParses the Validation.QueryParamName value out of a raw query string.
GrantScopeAdds a scope to an existing key.
HasScopeReturns True if the key carries the given scope.
ImportKeysStream-based import of keys and audit log.
IsConnectionAllowedServer hook enforcing the optional IPAllowlist when FailClosed is True.
IsExpiredReturns True if the key is past its expiry.
IsMessageAllowedServer hook called for every inbound message; IP-level no-op by default.
IsRequestAuthorizedOne-shot authorization check: extracts the key from headers or query string and validates it.
IsRevokedReturns True if the key is revoked.
IssueKeyGenerates, hashes and stores a new key; returns the plaintext (only time it can be observed).
KeyExistsReturns True if the key is known (active, revoked, expired or rotated).
ListScopesReturns the scopes attached to a key.
LoadFromFileRestores keys and audit log from file.
PurgeExpiredRemoves all keys whose ExpiresAt is in the past.
RegisterConnectionTracks a new connection. Called automatically by the server.
RenewKeyExtends the key's expiration by the given number of seconds from now.
RevokeKeyMarks a key as revoked; subsequent ValidateKey calls return False.
RevokeScopeRemoves a scope from an existing key.
RotateKeyIssues a fresh key for the same owner and scopes and marks the old one kksRotated.
SaveToFilePersists keys and audit log to the given file (falls back to Storage.FileName when empty).
UnregisterConnectionReleases tracking for a connection. Called automatically on disconnect.
ValidateKeyValidates a raw key and optionally enforces a required scope and records the requester's IP.