Documentation
¶
Overview ¶
Package tokens manages token authentication
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AuthenticatedPrefixes = []string{ tfeapi.APIPrefixV2, tfeapi.ModuleV1Prefix, otfhttp.APIBasePath, paths.UIPrefix, }
AuthenticatedPrefixes are those URL path prefixes requiring authentication.
Functions ¶
Types ¶
type Authenticator ¶ added in v0.5.18
type JWTAuthenticator ¶ added in v0.5.18
type JWTAuthenticator struct {
Client JWTAuthenticatorClient
}
JWTAuthenticator authenticates requests possessing a header with a JWT token (i.e. API requests).
func (*JWTAuthenticator) Authenticate ¶ added in v0.5.18
func (a *JWTAuthenticator) Authenticate(w http.ResponseWriter, r *http.Request) (authz.Subject, error)
type JWTAuthenticatorClient ¶ added in v0.5.18
type Middleware ¶ added in v0.5.18
type Middleware struct {
Authenticators []Authenticator
// contains filtered or unexported fields
}
func (*Middleware) Authenticate ¶ added in v0.5.18
func (m *Middleware) Authenticate(next http.Handler) http.Handler
Authenticate is middleware that verifies that all requests to protected endpoints possess a valid token.
Where authentication succeeds, the authenticated subject is attached to the request context and the upstream handler is called.
type Service ¶ added in v0.2.2
type Service struct {
Middleware *Middleware
// contains filtered or unexported fields
}
func NewService ¶
func (Service) GetSubject ¶ added in v0.2.2
GetSubject retrieves the subject from a JWT.
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.
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.
type TokensService ¶
type TokensService = Service
Alias service to permit embedding it with other services in a struct without a name clash.