Class SessionContext<TSessionToken>
Provides an abstraction for handling user sessions and tokens.
Implements
Namespace: Singulink.Net.Http.Api.Service
Assembly: Singulink.Net.Http.Api.Service.dll
Syntax
public abstract class SessionContext<TSessionToken> : IBindableFromHttpContext<SessionContext<TSessionToken>> where TSessionToken : class, ISessionToken
Type Parameters
| Name | Description |
|---|---|
| TSessionToken | The session token type. |
Properties
| Name | Description |
|---|---|
| Device | Gets a string that represents the device information that is making the current request. |
| IpAddress | Gets the IP address of the current request. If the IP address cannot be determined, returns null. |
Methods
| Name | Description |
|---|---|
| ClearToken() | Clears the session cookie for the current request user. Subsequent token retrievals in the current request return null, and any pending deferred token refresh is cancelled. |
| GetRequiredTokenAsync(SessionAccessOptions) | Gets the session token from the current request. If the user is not signed in, throws an UnauthorizedApiException. |
| GetTokenAsync(SessionAccessOptions) | Gets the session token from the current request. If the user is not signed in, returns null. |
| IsRequestOriginAllowed() | Validates the current request origin against allowed origins. If the request contains an origin identifier, it must match one of the allowed origins. |
| SetToken(TSessionToken) | Sets the session cookie for the current request user to the specified session token. Subsequent token retrievals in the current request return the specified token, and any pending deferred token refresh is cancelled. |
| SignInAsync(bool, Func<SignInInfo, Task<TSessionToken>>) | Signs in a user by creating a new session using the provided function and setting the session cookie to the session token returned by the function. |
| SignOutAsync() | Signs out the current request user by invalidating the session and clearing the session cookie. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IBindableFromHttpContext<SessionContext<TSessionToken>>.BindAsync(HttpContext, ParameterInfo) | Binds the SessionContext<TSessionToken> parameter value. |