session

package
v0.0.0-...-599a714 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package session provides functionality for providing auth based on session cookies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserInfoFromContext

func UserInfoFromContext(ctx context.Context) (*authn.UserInfo, bool)

Types

type Auth

type Auth interface {
	VerifyIDToken(ctx context.Context, idToken string) (*authn.Token, error)
	SessionCookie(ctx context.Context, idToken string, expiresIn time.Duration) (string, error)
	VerifySessionCookie(ctx context.Context, sessionCookie string) (*authn.Token, error)
	RevokeRefreshTokens(ctx context.Context, uID authn.UserID) error
}

Auth represents a backing auth system that can handle token verification and session management. It's usually represented by a *fireauth.Client.

type Client

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

func New

func New(auth Auth, db DB, logger *zap.Logger) *Client

func (*Client) LoginHandler

func (c *Client) LoginHandler() http.Handler

func (*Client) LogoutHandler

func (c *Client) LogoutHandler() http.Handler

func (*Client) WithAuthorization

func (c *Client) WithAuthorization(next http.Handler, loginHandlerPath string) http.Handler

type DB

type DB interface {
	Transactional(context.Context, func(tx db.Tx) error) error
	NoTxn(context.Context) db.Tx
	UserByAuthnProvider(tx db.Tx, provider authn.Provider, userID authn.UserID) (*todo.User, error)
	CreateUser(tx db.Tx, provider authn.Provider, authID authn.UserID, name, email string) (todo.UserID, error)
}

DB represents a storage system for storing information about users, and creating a use-case specific UserID, rather than using the Authorization system's UserID. This storage system is responsible only to have transactional semantics and the ability to create a user, and retrieve back that same user when requested via the same input Authorization IDs.

type LoginRequest

type LoginRequest struct {
	Name      string `json:"name"`
	IDToken   string `json:"idToken"`
	CSRFToken string `json:"csrfToken"`
}

LoginRequest represents the format we expect to receive for session login requests, usually in the JSON-formatted body of a POST request.

Jump to

Keyboard shortcuts

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