Table of Contents

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

cutoffUtc DateTime
cancellationToken CancellationToken

Returns

Task<DatabaseResult<int>>

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

tokenHash string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<AuthTokenData>>

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

tokenHash string

SHA-256 hex hash of the signed token blob.

accountName string

The account the token was issued for.

loginServerId long

The LoginServer that issued the token.

expiresUtc DateTime

When the token expires.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<AuthTokenData>>

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

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

RevokeByHashAsync(string, CancellationToken)

Revokes a specific token by its hash.

Task<DatabaseResult> RevokeByHashAsync(string tokenHash, CancellationToken cancellationToken = default)

Parameters

tokenHash string
cancellationToken CancellationToken

Returns

Task<DatabaseResult>