auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResetTokenInvalid = errors.New("invalid or expired reset token")
)

Functions

func NewAccessToken

func NewAccessToken(userID, secret string, ttlMinutes int) (string, error)

func NewRefreshToken

func NewRefreshToken(userID, secret string, ttlDays int) (string, string, time.Time, error)

Types

type Claims

type Claims struct {
	UserID    string `json:"uid"`
	TokenType string `json:"typ"`
	jwt.RegisteredClaims
}

func Parse

func Parse(tokenStr, secret string) (*Claims, error)

type RefreshStore

type RefreshStore interface {
	SaveRefresh(ctx context.Context, jti, userID, token string, expiresAt time.Time, rotatedFrom *string) error
	IsValid(ctx context.Context, jti, token string) (bool, string, time.Time, error)
	Revoke(ctx context.Context, jti string) error
	RevokeAllForUser(ctx context.Context, userID string) error
}

func NewRefreshStore

func NewRefreshStore(db *sql.DB, q *repo.Queries) RefreshStore

type ResetStore

type ResetStore interface {
	CreateResetToken(userID string) (plainToken string, err error)
	ValidateAndConsume(token string) (userID string, err error)
}

func NewResetStore

func NewResetStore(q *repo.Queries) ResetStore

type TokenPair

type TokenPair struct {
	AcessToken   string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

Jump to

Keyboard shortcuts

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