tokens

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package tokens manages token authentication

Index

Constants

View Source
const (
	// session cookie stores the session token
	SessionCookie = "session"
)

Variables

AuthenticatedPrefixes are those URL path prefixes requiring authentication.

Functions

func TokenFlashMessage added in v0.2.0

func TokenFlashMessage(renderer html.Renderer, w http.ResponseWriter, token []byte) error

TokenFlashMessage is a helper for rendering a flash message with an authentication token.

Types

type GetOrCreateUser added in v0.3.6

type GetOrCreateUser func(ctx context.Context, username string) (authz.Subject, error)

GetOrCreateUser retrieves the user with the given username. If the user does not exist it is created.

type GoogleIAPConfig

type GoogleIAPConfig struct {
	Audience string
}

type NewTokenOption added in v0.3.6

type NewTokenOption func(*jwt.Builder) *jwt.Builder

func WithExpiry added in v0.3.6

func WithExpiry(exp time.Time) NewTokenOption

type Options

type Options struct {
	logr.Logger
	GoogleIAPConfig

	Secret []byte
}

type Service added in v0.2.2

type Service struct {
	logr.Logger
	// contains filtered or unexported fields
}

func NewService

func NewService(opts Options) (*Service, error)

func (Service) GetSubject added in v0.2.2

func (r Service) GetSubject(ctx context.Context, jwtSubject resource.ID) (authz.Subject, error)

func (*Service) Middleware added in v0.2.2

func (a *Service) Middleware() mux.MiddlewareFunc

Middleware returns middleware for authenticating tokens

func (Service) NewToken added in v0.2.2

func (f Service) NewToken(subjectID resource.ID, opts ...NewTokenOption) ([]byte, error)

func (Service) RegisterKind added in v0.2.2

func (r Service) RegisterKind(k resource.Kind, fn SubjectGetter)

RegisterKind registers a kind of authentication token, providing a func that can retrieve the OTF subject indicated in the token.

func (Service) RegisterSiteToken added in v0.2.2

func (r Service) RegisterSiteToken(token string, siteAdmin authz.Subject)

RegisterSiteToken registers a site token which the middleware, and the subject to return as the site admin upon successful authentication.

func (*Service) StartSession added in v0.2.2

func (a *Service) StartSession(w http.ResponseWriter, r *http.Request, userID resource.ID) error

type SubjectGetter added in v0.2.0

type SubjectGetter func(ctx context.Context, jwtSubject resource.ID) (authz.Subject, error)

SubjectGetter retrieves an OTF subject given the jwtSubject string, which is the value of the 'subject' field parsed from a JWT.

Jump to

Keyboard shortcuts

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