Documentation ¶
Overview ¶
Package tokens manages token authentication
Index ¶
- Constants
- Variables
- func NewTestSessionJWT(t *testing.T, username string, secret []byte, lifetime time.Duration) string
- func TokenFlashMessage(renderer html.Renderer, w http.ResponseWriter, token []byte) error
- type GoogleIAPConfig
- type Kind
- type NewTokenOptions
- type Options
- type Service
- func (r Service) GetOrCreateUISubject(ctx context.Context, login string) (internal.Subject, error)
- func (r Service) GetSubject(ctx context.Context, k Kind, jwtSubject string) (internal.Subject, error)
- func (a *Service) Middleware() mux.MiddlewareFunc
- func (f Service) NewSessionToken(username string, expiry time.Time) (string, error)
- func (f Service) NewToken(opts NewTokenOptions) ([]byte, error)
- func (r Service) RegisterKind(k Kind, fn SubjectGetter)
- func (r Service) RegisterSiteToken(token string, siteAdmin internal.Subject)
- func (r Service) RegisterUISubjectGetterOrCreator(fn UISubjectGetterOrCreator)
- func (a *Service) StartSession(w http.ResponseWriter, r *http.Request, opts StartSessionOptions) error
- type StartSessionOptions
- type SubjectGetter
- type UISubjectGetterOrCreator
Constants ¶
const (
// session cookie stores the session token
SessionCookie = "session"
)
Variables ¶
var AuthenticatedPrefixes = []string{ tfeapi.APIPrefixV2, tfeapi.ModuleV1Prefix, otfapi.DefaultBasePath, paths.UIPrefix, }
AuthenticatedPrefixes are those URL path prefixes requiring authentication.
Functions ¶
func NewTestSessionJWT ¶
func TokenFlashMessage ¶ added in v0.2.0
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 Service ¶ added in v0.2.2
func NewService ¶
func (Service) GetOrCreateUISubject ¶ added in v0.2.2
func (Service) GetSubject ¶ added in v0.2.2
func (*Service) Middleware ¶ added in v0.2.2
func (a *Service) Middleware() mux.MiddlewareFunc
Middleware returns middleware for authenticating tokens
func (Service) NewSessionToken ¶ added in v0.2.2
func (Service) NewToken ¶ added in v0.2.2
func (f Service) NewToken(opts NewTokenOptions) ([]byte, error)
func (Service) RegisterKind ¶ added in v0.2.2
func (r Service) RegisterKind(k 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
RegisterSiteToken registers a site token which the middleware, and the subject to return as the site admin upon successful authentication.
func (Service) RegisterUISubjectGetterOrCreator ¶ added in v0.2.2
func (r Service) RegisterUISubjectGetterOrCreator(fn UISubjectGetterOrCreator)
func (*Service) StartSession ¶ added in v0.2.2
func (a *Service) StartSession(w http.ResponseWriter, r *http.Request, opts StartSessionOptions) error
type StartSessionOptions ¶
type SubjectGetter ¶ added in v0.2.0
SubjectGetter retrieves an OTF subject given the jwtSubject string, which is the value of the 'subject' field parsed from a JWT.