session

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package session maintains a Redis-backed revocation list for JWT sessions, keyed by the token's jti claim.

Index

Constants

View Source
const ResetSessionTTL = 15 * time.Minute

ResetSessionTTL bounds how long a forced-password-change reset token is valid.

Variables

View Source
var ErrResetSession = errors.New("reset session is invalid or has expired")

ErrResetSession is returned when a reset-session token is missing, expired, or already used.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(client *redis.Client) *Store

func (*Store) ConsumeResetSession added in v1.1.0

func (s *Store) ConsumeResetSession(ctx context.Context, token string) (uint, error)

ConsumeResetSession atomically validates and deletes a reset token, returning the user it belongs to. Single-use: a second call with the same token fails.

func (*Store) CreateResetSession added in v1.1.0

func (s *Store) CreateResetSession(ctx context.Context, userID uint) (string, error)

CreateResetSession stores a short-lived, single-use token authorizing exactly one action — setting a new password for userID — and returns it. Used by the forced-password-change flow so a user with an admin-set/reset password never receives a full session until they've chosen their own password.

func (*Store) IsRevoked

func (s *Store) IsRevoked(ctx context.Context, jti string) bool

IsRevoked reports whether a jti is blacklisted. Fails open on Redis errors.

func (*Store) MarkRevoked

func (s *Store) MarkRevoked(ctx context.Context, jti string, expiresAt time.Time)

MarkRevoked blacklists a jti until its natural expiry.

Jump to

Keyboard shortcuts

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