session

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 8 Imported by: 0

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