session

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: GPL-3.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Model Rocket API Session Library

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSessionExpired should be returned by stores for expired sessions
	ErrSessionExpired = errors.New("session expired")
)

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// SessionLoad loads a session by id
	SessionLoad(ctx context.Context, id string) (Session, error)

	// SessionCreate creates a session
	SessionCreate(ctx context.Context, session *Session) error

	// SessionUpdate updates a session
	SessionUpdate(ctx context.Context, session *Session) error

	// SessionDestroy destroys a session by id
	SessionDestroy(ctx context.Context, id string) error

	// SessionOptions returns the options from the audience
	SessionOptions(ctx context.Context, aud string) (Options, error)

	// SessionCleanup should remove expired sessions from the store
	SessionCleanup(ctx context.Context) error
}

Controller represents the backend session storage interface

type Manager

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

Manager store is a session store

func NewManager

func NewManager(ctrl Controller) *Manager

NewManager gets a store manager

func (*Manager) GetStore

func (s *Manager) GetStore(ctx context.Context, aud string, sub ...string) (sessions.Store, error)

GetStore gets a store for the given context

type Options

type Options struct {
	sessions.Options
	KeyPairs [][]byte
	// contains filtered or unexported fields
}

Options provide cookie hashing and encryption

type Session

type Session struct {
	ID        string     `json:"id"`
	Audience  string     `json:"aud"`
	Subject   string     `json:"sub"`
	Data      string     `json:"data"`
	CreatedAt time.Time  `json:"iat"`
	ExpiresAt time.Time  `json:"exp"`
	RevokedAt *time.Time `json:"rev,omitempty"`
}

Session represents an oauth session stored in a browser cookie and backed by the controller

Jump to

Keyboard shortcuts

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