Documentation
¶
Index ¶
- type Session
- func (sess *Session) Claims() token.Claims
- func (sess *Session) Del(ctx context.Context, key string) error
- func (sess *Session) Destroy(ctx context.Context) error
- func (sess *Session) Get(ctx context.Context, key string) kit.AnyValue
- func (sess *Session) Set(ctx context.Context, key string, val any) error
- type SessionProvider
- func (rsp *SessionProvider) Get(ctx *mist.Context) (token.Session, error)
- func (rsp *SessionProvider) InitSession(ctx *mist.Context, uid int64, jwtData map[string]string, ...) (token.Session, error)
- func (rsp *SessionProvider) RenewAccessToken(ctx *mist.Context) error
- func (rsp *SessionProvider) UpdateClaims(ctx *mist.Context, claims token.Claims) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session object is a representation of the Redis-backed session store. Implements the token.Session interface.
func (*Session) Claims ¶
Claims method returns the claims associated with the session. Returns: - token.Claims: The set of claims.
func (*Session) Del ¶
Del method removes a specific field from the Session in Redis. Parameters: - ctx: The context carrying deadline and cancellation information. - key: The key of the field within the session data. Returns: - error: Potential error during field deletion.
func (*Session) Destroy ¶
Destroy method deletes the entire Session from Redis. Parameters: - ctx: The context carrying deadline and cancellation information. Returns: - error: Potential error during session deletion.
func (*Session) Get ¶
Get method fetches a field from the session in Redis. Parameters: - ctx: The context carrying deadline and cancellation information. - key: The key of the field within the session. Returns: - kit.AnyValue: The value of the fetched field or an error if the fetching failed.
func (*Session) Set ¶
Set method saves a field with a specific value to the session in Redis. Parameters: - ctx: The context carrying deadline and cancellation information. - key: The key of the field in the session data. - val: The value to be saved in the session data. Returns: - error: Potential error during session field update.
type SessionProvider ¶
type SessionProvider struct {
// contains filtered or unexported fields
}
SessionProvider is responsible for managing session tokens using a JWT manager and a Redis client.
func InitSessionProvider ¶
func InitSessionProvider(client redis.Cmdable, jwtKey string) *SessionProvider
InitSessionProvider initializes a new SessionProvider with specified Redis client and JWT settings. Parameters: - client: The Redis client used for session data storage. - jwtKey: The secret key used to sign and verify JWT tokens. Returns: - *SessionProvider: A pointer to the newly created SessionProvider instance configured with the provided Redis client and JWT manager.
func (*SessionProvider) Get ¶
Get attempts to retrieve an existing session or establishes a new one based on a verified access token. Parameters: - ctx: The request context including session data and request/response utilities. Returns: - token.Session: The existing or newly established session. - error: An error if the access token verification fails or session initialization encounters an error.
func (*SessionProvider) InitSession ¶
func (rsp *SessionProvider) InitSession(ctx *mist.Context, uid int64, jwtData map[string]string, sessData map[string]any) (token.Session, error)
InitSession initializes a session for a user with provided UID and JWT data. Parameters: - ctx: The request context including headers and session information. - uid: The user identifier for whom the session is to be created. - jwtData: JWT claims to be included in the token. - sessData: Session-specific data that needs to be persisted. Returns: - token.Session: A newly created session object or nil on error. - error: Any error that occurs during initialization of the session.
func (*SessionProvider) RenewAccessToken ¶
func (rsp *SessionProvider) RenewAccessToken(ctx *mist.Context) error
RenewAccessToken handles the renewal of an access token using a refresh token. Parameters: - ctx: The request context containing session information and headers. Returns: - error: Any error occurred during refreshing the token or if the refresh token is expired.
func (*SessionProvider) UpdateClaims ¶
UpdateClaims handles updating the session with new JWT claims. Parameters: - ctx: The request context containing headers and session data. - claims: The claims to embed within the generated JWT. Returns: - error: Any error encountered during access or refresh token generation.