Table of Contents

Interface IAuthTokenService

Namespace
GastroSky.Services.AuthTokenService
Assembly
GastroSky.dll
public interface IAuthTokenService

Methods

EmitAuthTokenForUserAccount(User)

Emits a new authentication token for a given userAccount.

string EmitAuthTokenForUserAccount(User userAccount)

Parameters

userAccount User

The User for whom to generate the token.

Returns

string

The token string ready for the user to append to his subsequent requests (inside the Authorization HTTP header with the Bearer prefix).

EmitDefibrillatorTokenForUserAccount(User)

Emits a new defibrillator token useful for reviving dead sessions (expired).

Defi-Tokens have a slightly longer lifetime, but need to be handled with the same (if not more) care as the normal auth tokens.
string EmitDefibrillatorTokenForUserAccount(User userAccount)

Parameters

userAccount User

The User for whom to generate the token.

Returns

string

The defibrillator token string.

ExtractJwt(HttpContext)

Extracts the authorization header value from a request's HttpContext.

string? ExtractJwt(HttpContext httpContext)

Parameters

httpContext HttpContext

HTTP request's HttpContext to extract the token from.

Returns

string

The found JWT (null if no auth token was found inside the request's authorization header).

ValidateReviveRequest(ReviveRequestDto)

Checks whether a defibrillator token that was emitted by the EmitDefibrillatorTokenForUserAccount(User) method is valid or not.

string? ValidateReviveRequest(ReviveRequestDto dto)

Parameters

dto ReviveRequestDto

The revival request DTO to check.

Returns

string

null if validation failed; the sub claim value if validation was successful (which should correspond to the User's Slug value).

Remarks

This will NOT obliterate the token: do not forget to do that in case of validity and renewal!