Documentation ¶
Index ¶
- func GenerateMockJWT(subject, issuer, audience string) string
- func NewAuthenticator(iss, aud string, groups []string, connID, userID, email string, ...) authenticator.Authenticator
- func NewHeaderTokenAuthenticator(header string, tokens map[string]string, logger *zap.Logger) authenticator.Authenticator
- func NewStaticAuthenticator(externalID, connID, userID, email string, teams []string, logger *zap.Logger) authenticator.Authenticator
- func NewStaticFailWithRequestorAuthenticator(requestor string, err error) authenticator.Authenticator
- type HeaderTokenAuthenticator
- type HeaderTokenConfig
- type OidcAuthenticator
- type OidcConfig
- type StaticAuthenticator
- type StaticConfig
- type StaticFailWithRequestorAuthenticator
- type StaticFailWithRequestorConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateMockJWT ¶
GenerateMockJWT generates a JWT ID token containing the passed sub/iss/aud claims. It is signed using HS256 with the secret "sharedsecret" -- only to be used for mocking tests.
func NewAuthenticator ¶
func NewAuthenticator(iss, aud string, groups []string, connID, userID, email string, logger *zap.Logger) authenticator.Authenticator
NewAuthenticator returns a mock authenticator which requires no server interaction. It only checks claims and returns their name.
func NewHeaderTokenAuthenticator ¶
func NewHeaderTokenAuthenticator( header string, tokens map[string]string, logger *zap.Logger) authenticator.Authenticator
NewHeaderTokenAuthenticator returns a mock authenticator which requires no server interaction. It only checks hard-coded tokens from the configured header.
func NewStaticAuthenticator ¶
func NewStaticAuthenticator(externalID, connID, userID, email string, teams []string, logger *zap.Logger) authenticator.Authenticator
NewStaticAuthenticator returns a mock authenticator that always returns the passed requestor, its type, and connID. Only useful for dev and testing.
func NewStaticFailWithRequestorAuthenticator ¶
func NewStaticFailWithRequestorAuthenticator(requestor string, err error) authenticator.Authenticator
NewStaticFailWithRequestorAuthenticator returns a mock authenticator always returns the passed requestor. Only for testing.
Types ¶
type HeaderTokenAuthenticator ¶
type HeaderTokenAuthenticator struct {
// contains filtered or unexported fields
}
HeaderTokenAuthenticator is used for configuring static header-token authenticators
func (*HeaderTokenAuthenticator) Authenticate ¶
func (a *HeaderTokenAuthenticator) Authenticate(r *http.Request) (authenticator.Requestor, error)
Authenticate processes the passed request, checking if the configured header's FIRST value matches any of the the hard-coded tokens list.
type HeaderTokenConfig ¶
type HeaderTokenConfig struct { Header string `json:"header"` Tokens map[string]string `json:"tokens"` }
HeaderTokenConfig is used for configuring static header-token authenticators
func (*HeaderTokenConfig) Open ¶
func (c *HeaderTokenConfig) Open(u *url.URL, _ *certs.ServiceCerts, logger *zap.Logger, _ id_token.ValidateIdTokenServiceClient) (authenticator.Authenticator, error)
Open returns an header token authenticator
type OidcAuthenticator ¶
type OidcAuthenticator struct {
// contains filtered or unexported fields
}
OidcAuthenticator is used for configuring mock-oidc authenticators
func (*OidcAuthenticator) Authenticate ¶
func (a *OidcAuthenticator) Authenticate(r *http.Request) (authenticator.Requestor, error)
Authenticate processes the passed request, checking its ID token in the `Authorization: Bearer XY` header
type OidcConfig ¶
type OidcConfig struct { Issuer string `json:"issuer"` Audience string `json:"client_id"` Groups []string `json:"groups"` ConnID string `json:"conn_id"` UserID string `json:"user_id"` Email string }
OidcConfig is used for configuring mock-oidc authenticators
func (*OidcConfig) Open ¶
func (c *OidcConfig) Open(_ *url.URL, _ *certs.ServiceCerts, logger *zap.Logger, _ id_token.ValidateIdTokenServiceClient) (authenticator.Authenticator, error)
Open returns an authentication strategy that statically checks the iss and aud claims only
type StaticAuthenticator ¶
type StaticAuthenticator struct {
// contains filtered or unexported fields
}
StaticAuthenticator holds the state of a mock-static authenticator
func (*StaticAuthenticator) Authenticate ¶
func (a *StaticAuthenticator) Authenticate(r *http.Request) (authenticator.Requestor, error)
Authenticate processes the passed request, checking its ID token in the `Authorization: Bearer XY` header
type StaticConfig ¶
type StaticConfig struct { ExternalID string `json:"external_id"` ConnID string `json:"conn_id"` UserID string `json:"user_id"` Teams []string `json:"teams"` Email string }
StaticConfig is used for configuring mock-static authenticators
func (*StaticConfig) Open ¶
func (c *StaticConfig) Open(u *url.URL, _ *certs.ServiceCerts, logger *zap.Logger, _ id_token.ValidateIdTokenServiceClient) (authenticator.Authenticator, error)
Open returns an authentication strategy that always returns the configured requestor.
type StaticFailWithRequestorAuthenticator ¶
type StaticFailWithRequestorAuthenticator struct {
// contains filtered or unexported fields
}
StaticFailWithRequestorAuthenticator holds the state of the fail_with_requestor authenticator
func (*StaticFailWithRequestorAuthenticator) Authenticate ¶
func (a *StaticFailWithRequestorAuthenticator) Authenticate(r *http.Request) (authenticator.Requestor, error)
Authenticate returns the configured requestor AND the configured error != nil
type StaticFailWithRequestorConfig ¶
type StaticFailWithRequestorConfig struct { Requestor string `json:"requestor"` ErrorMsg string `json:"error"` }
StaticFailWithRequestorConfig is used for configuring the fail_with_requestor authenticator Note: This config is NOT exposed in server/authenticators.go, so it can't be chosen for any
purpose outside of tests -- because it really shouldn't.
func (*StaticFailWithRequestorConfig) Open ¶
func (c *StaticFailWithRequestorConfig) Open(u *url.URL, _ *certs.ServiceCerts, logger *zap.Logger) (authenticator.Authenticator, error)
Open returns an authentication strategy that always returns the configured requestor AND an error != nil.