tokens

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MPL-2.0 Imports: 27 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 NewService

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

func NewTestSessionJWT

func NewTestSessionJWT(t *testing.T, username string, secret []byte, lifetime time.Duration) string

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 GoogleIAPConfig

type GoogleIAPConfig struct {
	Audience string
}

type Kind

type Kind string

the Kind of authentication token: user session, user token, agent token, etc

type NewTokenOptions

type NewTokenOptions struct {
	Kind    Kind
	Subject string
	Expiry  *time.Time
	Claims  map[string]string
}

type Options

type Options struct {
	logr.Logger
	GoogleIAPConfig

	Secret []byte
}

type StartSessionOptions

type StartSessionOptions struct {
	Username *string
	Expiry   *time.Time
}

type SubjectGetter added in v0.2.0

type SubjectGetter func(ctx context.Context, jwtSubject string) (internal.Subject, error)

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

type TokensService

type TokensService interface {
	Middleware() mux.MiddlewareFunc
	NewToken(NewTokenOptions) ([]byte, error)
	RegisterKind(Kind, SubjectGetter)
	RegisterSiteToken(token string, siteAdmin internal.Subject)
	RegisterUISubjectGetterOrCreator(fn UISubjectGetterOrCreator)
	NewSessionToken(username string, expiry time.Time) (string, error)
	// contains filtered or unexported methods
}

type UISubjectGetterOrCreator added in v0.2.0

type UISubjectGetterOrCreator func(ctx context.Context, login string) (internal.Subject, error)

UISubjectGetterOrCreator retrieves the OTF subject with the given login that is attempting to access the UI. If the subject does not exist it is created.

Jump to

Keyboard shortcuts

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