session

package
v0.233.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package session keeps the in-memory state that ties a logged-in user to the tokens the mock has issued, so later requests (/userinfo) can see the same user the id_token described.

Index

Constants

View Source
const MaxEntries = 10000

MaxEntries bounds how many user profiles, and separately how many refresh grants, opaque access tokens and login sessions, the store keeps; the oldest inserted entry of a kind is evicted when a new one arrives at the limit.

Variables

This section is empty.

Functions

This section is empty.

Types

type Access

type Access struct {
	Subject, ClientID, Scope string
	ExpiresAt                time.Time
}

Access is what the mock remembers about an opaque access token, issued when there is no audience to mint a JWT for, so /userinfo can resolve it.

type Grant

type Grant struct {
	Subject, ClientID, Audience, Scope, Realm string
	AuthTime                                  time.Time
	Profile                                   map[string]any
}

Grant is what the mock remembers about a refresh token it issued, so the refresh_token grant can return the same user.

type Login

type Login struct {
	Subject  string
	AuthTime time.Time
}

Login is a mock login session: who signed in and when, kept server-side behind the auth0 cookie so a later prompt=none request can answer for them.

type Store

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

Store is a mutex-guarded session registry.

func NewStore

func NewStore() *Store

NewStore returns an empty Store.

func (*Store) Access

func (s *Store) Access(token string) (Access, bool)

Access returns the record remembered for the opaque access token.

func (*Store) Clear

func (s *Store) Clear()

Clear forgets everything.

func (*Store) EndLogin

func (s *Store) EndLogin(id string)

EndLogin forgets the login session with the given id; unknown ids are ignored.

func (*Store) Login

func (s *Store) Login(id string) (Login, bool)

Login returns the login session with the given id.

func (*Store) Profile

func (s *Store) Profile(subject string) (map[string]any, bool)

Profile returns a copy of the profile last remembered for subject.

func (*Store) Refresh

func (s *Store) Refresh(token string) (Grant, bool)

Refresh returns a copy of the grant remembered for the refresh token.

func (*Store) RememberAccess

func (s *Store) RememberAccess(token string, a Access)

RememberAccess stores a under the opaque access token. It is bounded by MaxEntries like refresh grants, evicting the oldest token first.

func (*Store) RememberProfile

func (s *Store) RememberProfile(subject string, profile map[string]any)

RememberProfile stores a copy of profile for subject; last write wins.

func (*Store) RememberRefresh

func (s *Store) RememberRefresh(token string, g Grant)

RememberRefresh stores a copy of g under the refresh token. It is bounded by MaxEntries like profiles, evicting the oldest token first.

func (*Store) StartLogin

func (s *Store) StartLogin(subject string, authTime time.Time) string

StartLogin records a login session for subject and returns its random id. It is bounded by MaxEntries like the other maps, evicting the oldest first.

Jump to

Keyboard shortcuts

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