sessionstorage

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sessionstorage implements database storage for session data. There are implementations for both Spanner and Postgres for each session type (i.e. OIDC, Username/Password, etc)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseStore added in v0.6.1

type BaseStore interface {
	// Session returns the session information from the database for given sessionID
	Session(ctx context.Context, sessionID ccc.UUID) (*sessioninfo.SessionInfo, error)
	// UpdateSessionActivity updates the database with the current time for the session activity
	UpdateSessionActivity(ctx context.Context, sessionID ccc.UUID) error
	// DestroySession marks the session as expired
	DestroySession(ctx context.Context, sessionID ccc.UUID) error
	// SetSessionTableName sets the name of the session table.
	SetSessionTableName(name string)
	// SetUserTableName sets the name of the user table.
	SetUserTableName(name string)
}

BaseStore defines an interface for managing session storage.

type OIDC added in v0.6.1

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

OIDC is the session storage implementation for with OIDC support.

func NewPostgresOIDC

func NewPostgresOIDC(pg postgres.Queryer) *OIDC

NewPostgresOIDC creates a new PostgresOIDC instance.

func NewSpannerOIDC

func NewSpannerOIDC(client *cloudspanner.Client) *OIDC

NewSpannerOIDC creates a new SpannerOIDCSessionStorage instance.

func (*OIDC) DestroySession added in v0.6.1

func (s *OIDC) DestroySession(ctx context.Context, sessionID ccc.UUID) error

DestroySession marks the session as expired

func (*OIDC) DestroySessionOIDC added in v0.6.1

func (s *OIDC) DestroySessionOIDC(ctx context.Context, oidcSID string) error

DestroySessionOIDC marks the session as expired

func (*OIDC) NewSession added in v0.6.1

func (s *OIDC) NewSession(ctx context.Context, username, oidcSID string) (ccc.UUID, error)

NewSession inserts SessionInfo into database

func (*OIDC) Session added in v0.6.1

func (s *OIDC) Session(ctx context.Context, sessionID ccc.UUID) (*sessioninfo.SessionInfo, error)

Session returns the session information from the database for given sessionID

func (*OIDC) SetSessionTableName added in v0.6.1

func (s *OIDC) SetSessionTableName(name string)

SetSessionTableName sets the name of the session table.

func (*OIDC) SetUserTableName added in v0.6.1

func (s *OIDC) SetUserTableName(name string)

SetUserTableName sets the name of the user table.

func (*OIDC) UpdateSessionActivity added in v0.6.1

func (s *OIDC) UpdateSessionActivity(ctx context.Context, sessionID ccc.UUID) error

UpdateSessionActivity updates the database with the current time for the session activity

type OIDCStore added in v0.6.1

type OIDCStore interface {
	DestroySessionOIDC(ctx context.Context, oidcSID string) error
	NewSession(ctx context.Context, username, oidcSID string) (ccc.UUID, error)

	// shared storage methods
	BaseStore
}

OIDCStore defines an interface for managing OIDC session storage.

type PasswordAuth added in v0.6.1

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

PasswordAuth is the session storage implementation with PasswordAuth support.

func NewPostgresPassword added in v0.6.1

func NewPostgresPassword(pg postgres.Queryer) *PasswordAuth

NewPostgresPassword creates a new PostgresPassword instance.

func NewSpannerPasswordAuth added in v0.6.1

func NewSpannerPasswordAuth(client *cloudspanner.Client) *PasswordAuth

NewSpannerPasswordAuth creates a new Password storage instance.

func (*PasswordAuth) ActivateUser added in v0.6.2

func (p *PasswordAuth) ActivateUser(ctx context.Context, id ccc.UUID) error

ActivateUser activates a user

func (*PasswordAuth) CreateUser added in v0.6.2

CreateUser creates a new user

func (*PasswordAuth) DeactivateUser added in v0.6.2

func (p *PasswordAuth) DeactivateUser(ctx context.Context, id ccc.UUID) error

DeactivateUser deactivates a user

func (*PasswordAuth) DeleteUser added in v0.6.2

func (p *PasswordAuth) DeleteUser(ctx context.Context, id ccc.UUID) error

DeleteUser deletes a user

func (*PasswordAuth) DestroyAllUserSessions added in v0.6.2

func (p *PasswordAuth) DestroyAllUserSessions(ctx context.Context, username string) error

DestroyAllUserSessions destroys all sessions for a given user

func (*PasswordAuth) DestroySession added in v0.6.1

func (s *PasswordAuth) DestroySession(ctx context.Context, sessionID ccc.UUID) error

DestroySession marks the session as expired

func (*PasswordAuth) NewSession added in v0.6.1

func (s *PasswordAuth) NewSession(ctx context.Context, username string) (ccc.UUID, error)

NewSession inserts SessionInfo into the spanner database

func (*PasswordAuth) Session added in v0.6.1

func (s *PasswordAuth) Session(ctx context.Context, sessionID ccc.UUID) (*sessioninfo.SessionInfo, error)

Session returns the session information from the database for given sessionID

func (*PasswordAuth) SetSessionTableName added in v0.6.1

func (s *PasswordAuth) SetSessionTableName(name string)

SetSessionTableName sets the name of the session table.

func (*PasswordAuth) SetUserPasswordHash added in v0.6.1

func (p *PasswordAuth) SetUserPasswordHash(ctx context.Context, id ccc.UUID, hash *securehash.Hash) error

SetUserPasswordHash updates the user password hash

func (*PasswordAuth) SetUserTableName added in v0.6.1

func (s *PasswordAuth) SetUserTableName(name string)

SetUserTableName sets the name of the user table.

func (*PasswordAuth) UpdateSessionActivity added in v0.6.1

func (s *PasswordAuth) UpdateSessionActivity(ctx context.Context, sessionID ccc.UUID) error

UpdateSessionActivity updates the database with the current time for the session activity

func (*PasswordAuth) User added in v0.6.1

func (p *PasswordAuth) User(ctx context.Context, id ccc.UUID) (*dbtype.SessionUser, error)

User returns the user record associated with the username

func (*PasswordAuth) UserByUserName added in v0.6.1

func (p *PasswordAuth) UserByUserName(ctx context.Context, username string) (*dbtype.SessionUser, error)

UserByUserName returns the user record associated with the username

type PasswordAuthStore added in v0.6.1

type PasswordAuthStore interface {
	// User returns a session user for give user id
	User(ctx context.Context, id ccc.UUID) (*dbtype.SessionUser, error)
	// UserByUsername returns a session user for give username
	UserByUserName(ctx context.Context, username string) (*dbtype.SessionUser, error)
	// SetUserPasswordHash updates the user password hash
	SetUserPasswordHash(ctx context.Context, id ccc.UUID, hash *securehash.Hash) error
	// ActivateUser activates a user
	ActivateUser(ctx context.Context, id ccc.UUID) error
	// CreateUser creates a new user
	CreateUser(ctx context.Context, user *dbtype.InsertSessionUser) (*dbtype.SessionUser, error)
	// DeactivateUser deactivates a user
	DeactivateUser(ctx context.Context, id ccc.UUID) error
	// DeleteUser deletes a user
	DeleteUser(ctx context.Context, id ccc.UUID) error
	// DestroyAllUserSessions destroys all sessions for a given user
	DestroyAllUserSessions(ctx context.Context, username string) error

	// shared storage methods
	PreauthStore
}

PasswordAuthStore defines an interface for managing password sessions.

type Preauth

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

Preauth is the session storage implementation for Preauth.

func NewPostgresPreauth

func NewPostgresPreauth(db postgres.Queryer) *Preauth

NewPostgresPreauth is the function that you use to create the session manager that handles the session creation and updates

func NewSpannerPreauth

func NewSpannerPreauth(db *cloudspanner.Client) *Preauth

NewSpannerPreauth is the function that you use to create the session manager that handles the session creation and updates

func (*Preauth) DestroySession added in v0.6.1

func (s *Preauth) DestroySession(ctx context.Context, sessionID ccc.UUID) error

DestroySession marks the session as expired

func (*Preauth) NewSession

func (s *Preauth) NewSession(ctx context.Context, username string) (ccc.UUID, error)

NewSession inserts SessionInfo into the spanner database

func (*Preauth) Session added in v0.6.1

func (s *Preauth) Session(ctx context.Context, sessionID ccc.UUID) (*sessioninfo.SessionInfo, error)

Session returns the session information from the database for given sessionID

func (*Preauth) SetSessionTableName added in v0.6.1

func (s *Preauth) SetSessionTableName(name string)

SetSessionTableName sets the name of the session table.

func (*Preauth) SetUserTableName added in v0.6.1

func (s *Preauth) SetUserTableName(name string)

SetUserTableName sets the name of the user table.

func (*Preauth) UpdateSessionActivity added in v0.6.1

func (s *Preauth) UpdateSessionActivity(ctx context.Context, sessionID ccc.UUID) error

UpdateSessionActivity updates the database with the current time for the session activity

type PreauthStore added in v0.6.1

type PreauthStore interface {
	// NewSession creates a new session in the database, returning its id
	NewSession(ctx context.Context, username string) (ccc.UUID, error)

	// shared storage methods
	BaseStore
}

PreauthStore defines an interface for managing pre-authenticated session storage.

Directories

Path Synopsis
internal
postgres
Package postgres implements the session storage driver for PostgreSQL.
Package postgres implements the session storage driver for PostgreSQL.
spanner
Package spanner provides the session storage driver for Spanner.
Package spanner provides the session storage driver for Spanner.
mock
mock_sessionstorage
Package mock_sessionstorage is a generated GoMock package.
Package mock_sessionstorage is a generated GoMock package.

Jump to

Keyboard shortcuts

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