Interface IAuthTokenService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
Service interface for managing authentication tokens. The LoginServer issues tokens after successful SRP authentication. WorldServers and SceneServers validate tokens cryptographically and check for revocation.
public interface IAuthTokenService
Methods
CleanupExpiredAsync(DateTime, CancellationToken)
Deletes expired tokens older than the specified cutoff. Returns the number of tokens deleted. Called periodically for database maintenance.
Task<DatabaseResult<int>> CleanupExpiredAsync(DateTime cutoffUtc, CancellationToken cancellationToken = default)
Parameters
cutoffUtcDateTimecancellationTokenCancellationToken
Returns
FetchByHashAsync(string, CancellationToken)
Fetches a token record by its hash for revocation checks. Returns failure if the token is not found.
Task<DatabaseResult<AuthTokenData>> FetchByHashAsync(string tokenHash, CancellationToken cancellationToken = default)
Parameters
tokenHashstringcancellationTokenCancellationToken
Returns
IssueAsync(string, string, long, DateTime, CancellationToken)
Records a newly issued authentication token. Called by the LoginServer after successful SRP authentication.
Task<DatabaseResult<AuthTokenData>> IssueAsync(string tokenHash, string accountName, long loginServerId, DateTime expiresUtc, CancellationToken cancellationToken = default)
Parameters
tokenHashstringSHA-256 hex hash of the signed token blob.
accountNamestringThe account the token was issued for.
loginServerIdlongThe LoginServer that issued the token.
expiresUtcDateTimeWhen the token expires.
cancellationTokenCancellationTokenCancellation token.
Returns
RevokeAllForAccountAsync(string, CancellationToken)
Revokes all active tokens for a specific account. Used when an account is banned, password is changed, or force-logout is required.
Task<DatabaseResult> RevokeAllForAccountAsync(string accountName, CancellationToken cancellationToken = default)
Parameters
accountNamestringcancellationTokenCancellationToken
Returns
RevokeByHashAsync(string, CancellationToken)
Revokes a specific token by its hash.
Task<DatabaseResult> RevokeByHashAsync(string tokenHash, CancellationToken cancellationToken = default)
Parameters
tokenHashstringcancellationTokenCancellationToken