Documentation
¶
Overview ¶
Package auth validates requests: an Azure AD token is tried first and, when the token isn't an Azure one (no kid, unknown kid), it falls back to a static RS256 key — for a secondary issuer, service-to-service tokens, or any other static key a deployment wants to trust alongside Azure AD.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotAzureToken = errors.New("not an azure ad token")
ErrNotAzureToken means the token has no kid or a kid unknown to Azure AD, so the legacy validation must be tried (InvalidAuthorizationToken in eve_azure_ad_auth).
ErrUnauthorized is returned for missing or invalid credentials.
Functions ¶
func TokenFromRequest ¶
TokenFromRequest extracts the token from the request, in this order:
Authorization: Basic base64(<token>:<anything>) -> the username Authorization: Token <token> Authorization: Basic: <token> -> a bare "Basic:" prefix Authorization: <token> Cookie: <cookieName>=<token>
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator validates requests.
func New ¶
func New(cfg Config, azure *AzureVerifier) (*Authenticator, error)
New builds an Authenticator. A PublicKeyFile that fails to read or parse fails New, so a typo in the config never silently disables the fallback.
func (*Authenticator) Authenticate ¶
func (a *Authenticator) Authenticate(r *http.Request) (Claims, error)
Authenticate validates the request token. With auth disabled it returns empty claims and no error.
func (*Authenticator) Azure ¶
func (a *Authenticator) Azure() *AzureVerifier
Azure returns the Azure verifier, or nil when Azure is not configured.
func (*Authenticator) Enabled ¶
func (a *Authenticator) Enabled() bool
Enabled reports whether authentication is enforced.
func (*Authenticator) VerifyLegacy ¶
func (a *Authenticator) VerifyLegacy(token string) (Claims, error)
VerifyLegacy validates a token against the static RS256 key (Config.PublicKeyFile); with authentication disabled every token is valid.
type AzureVerifier ¶
type AzureVerifier struct {
// contains filtered or unexported fields
}
AzureVerifier validates Azure AD v2.0 tokens, like eve_azure_ad_auth.verifier.AzureVerifier, caching the signing keys.
func NewAzureVerifier ¶
func NewAzureVerifier(tenant, issuer string, audiences []string) *AzureVerifier
NewAzureVerifier builds a verifier. An empty tenant means "common".
type Claims ¶
Claims is the decoded token payload.
func FromContext ¶
FromContext returns the claims of an authenticated request.
type Config ¶
type Config struct {
Enabled bool
// CookieName is read when no Authorization header carries a token
// (default "token").
CookieName string
// PublicKeyFile is the static RS256 key for the legacy fallback (PEM or
// "ssh-rsa ..."). Without it, that fallback is disabled: a non-Azure
// token is simply rejected.
PublicKeyFile string
Tenant string
Issuer string
Audiences []string
}
Config holds the authentication settings.