Interface ITokenStorage
- Namespace
- Stratara.Identity.Core.Abstractions
- Assembly
- Stratara.Identity.Core.dll
Channel-agnostic secure-storage surface for persisting and reading the current AccessTokenInfo. Implemented per host (server-side Blazor typically relies on the ASP.NET Core auth cookie and provides a no-op; non-web hosts use platform-native secure storage).
public interface ITokenStorage
- Extension Methods
Remarks
Implementations handle bearer credentials (see the security remarks on LoginResponse) and MUST persist them only in encrypted / platform-secure storage — e.g. the OS keychain on desktop / mobile, an HTTP-only cookie under TLS on the server. Never write tokens to plain files, unsecured preferences, or unencrypted application state.
Methods
GetTokenInfoFromSecureStorageAsync(CancellationToken)
Reads the persisted AccessTokenInfo from secure storage.
Task<AccessTokenInfo?> GetTokenInfoFromSecureStorageAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenPropagated to the underlying secure-storage read.
Returns
- Task<AccessTokenInfo>
The stored token info, or
nullwhen nothing is persisted or deserialization fails.
RemoveToken()
Removes any stored token from secure storage.
void RemoveToken()
SaveTokenToSecureStorageAsync(string, string, CancellationToken)
Persists a freshly issued token to secure storage.
Task<AccessTokenInfo?> SaveTokenToSecureStorageAsync(string token, string email, CancellationToken cancellationToken = default)
Parameters
tokenstringRaw token JSON as returned by the identity endpoint.
emailstringEmail address of the authenticated user.
cancellationTokenCancellationTokenPropagated to the underlying secure-storage write.
Returns
- Task<AccessTokenInfo>
The constructed AccessTokenInfo after writing, or
nullon failure.