session

package
v1.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package session provides a session manager for creating and verifying JWT tokens.

Index

Constants

View Source
const (
	// SessionManagerClaimsIssuer fills the "iss" field of the token.
	SessionManagerClaimsIssuer = "everest"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager provides functionality for creating and managing JWT tokens.

func New

func New(options ...Option) (*Manager, error)

New creates a new session manager with the given options.

func (*Manager) Authenticate

func (mgr *Manager) Authenticate(ctx context.Context, username string, password string) error

Authenticate verifies the given username and password.

func (*Manager) Create

func (mgr *Manager) Create(subject string, secondsBeforeExpiry int64, id string) (string, error)

Create creates a new token for a given subject (user) and returns it as a string. Passing a value of `0` for secondsBeforeExpiry creates a token that never expires. The id parameter holds an optional unique JWT token identifier and stored as a standard claim "jti" in the JWT token.

func (*Manager) KeyFunc

func (mgr *Manager) KeyFunc() jwt.Keyfunc

KeyFunc retruns a function for getting the public RSA keys used for verifying the JWT tokens signed by everest.

type Option

type Option func(*Manager)

Option is a function that modifies a SessionManager.

func WithAccountManager

func WithAccountManager(i accounts.Interface) Option

WithAccountManager sets the account manager to use for verifying user credentials.

Jump to

Keyboard shortcuts

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