Table of Contents

Interface IWebSessionService

Namespace
FishMMO.Database.Npgsql.Services.Interfaces
Assembly
FishMMO-DB.dll

Control Panel browser sessions.

public interface IWebSessionService

Remarks

Every method takes the SHA-256 hex of the session identifier, never the identifier itself. Hashing is the caller's job so the raw value never reaches this layer at all.

Methods

CleanupExpiredAsync(DateTime, CancellationToken)

Deletes sessions that expired before the cutoff. Returns how many rows went.

Task<DatabaseResult<int>> CleanupExpiredAsync(DateTime cutoffUtc, CancellationToken cancellationToken = default)

Parameters

cutoffUtc DateTime
cancellationToken CancellationToken

Returns

Task<DatabaseResult<int>>

FetchActiveForAccountAsync(string, CancellationToken)

Lists the live sessions for an account, newest first.

Task<DatabaseResult<List<WebSessionData>>> FetchActiveForAccountAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<List<WebSessionData>>>

FetchByHashAsync(string, CancellationToken)

Fetches a session by hash. Returns failure when it does not exist; the caller still has to apply the revoked, expiry and idle checks.

Task<DatabaseResult<WebSessionData>> FetchByHashAsync(string sessionHash, CancellationToken cancellationToken = default)

Parameters

sessionHash string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<WebSessionData>>

IssueAsync(string, string, byte, bool, DateTime, string, string, CancellationToken)

Records a newly issued session.

Task<DatabaseResult<WebSessionData>> IssueAsync(string sessionHash, string accountName, byte accessLevel, bool twoFactorSatisfied, DateTime expiresUtc, string ipAddress, string userAgent, CancellationToken cancellationToken = default)

Parameters

sessionHash string

SHA-256 hex of the session identifier.

accountName string

Account the session authenticates.

accessLevel byte

The account's access level at issue.

twoFactorSatisfied bool

Whether two-factor is already satisfied.

expiresUtc DateTime

Absolute expiry.

ipAddress string

Client address, or null.

userAgent string

Client user agent, or null.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<WebSessionData>>

PersistStepUpAsync(string, CancellationToken)

Stamps a fresh step-up, restarting the window for destructive actions.

Task<DatabaseResult> PersistStepUpAsync(string sessionHash, CancellationToken cancellationToken = default)

Parameters

sessionHash string
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

PersistTwoFactorSatisfiedAsync(string, DateTime, CancellationToken)

Marks two-factor satisfied and stamps the step-up time, promoting a pending session.

Task<DatabaseResult> PersistTwoFactorSatisfiedAsync(string sessionHash, DateTime expiresUtc, CancellationToken cancellationToken = default)

Parameters

sessionHash string
expiresUtc DateTime
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

RevokeAllForAccountAsync(string, CancellationToken)

Revokes every session for an account. Called when the account is banned, its access level changes, its password changes, or its tokens are revoked.

Task<DatabaseResult<int>> RevokeAllForAccountAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<int>>

RevokeByHashAsync(string, CancellationToken)

Revokes one session.

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

Parameters

sessionHash string
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

RevokeByIdAsync(string, long, CancellationToken)

Revokes one session by its surrogate id, for the operator's session list.

Task<DatabaseResult> RevokeByIdAsync(string accountName, long id, CancellationToken cancellationToken = default)

Parameters

accountName string
id long
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

TouchAsync(string, CancellationToken)

Stamps last-seen on a live session, extending its idle window.

Task<DatabaseResult> TouchAsync(string sessionHash, CancellationToken cancellationToken = default)

Parameters

sessionHash string
cancellationToken CancellationToken

Returns

Task<DatabaseResult>