redis

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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

func (sess *Session) Claims() token.Claims

Claims method returns the claims associated with the session. Returns: - token.Claims: The set of claims.

func (*Session) Del

func (sess *Session) Del(ctx context.Context, key string) error

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

func (sess *Session) Destroy(ctx context.Context) error

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

func (sess *Session) Get(ctx context.Context, key string) kit.AnyValue

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

func (sess *Session) Set(ctx context.Context, key string, val any) error

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

func (rsp *SessionProvider) Get(ctx *mist.Context) (token.Session, error)

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

func (rsp *SessionProvider) UpdateClaims(ctx *mist.Context, claims token.Claims) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL