Documentation
¶
Index ¶
- Constants
- Variables
- func ChunkString(input string, chunkSize int) []string
- func GenerateSessionId() string
- func LvOzrVvt() error
- func New(uctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error)
- func ParseBigInt(s string) (*big.Int, error)
- func ParseInt(s string) (int, error)
- type AuthorizationConfig
- type AuthorizationCookieConfig
- type AuthorizationHeaderConfig
- type ClaimAssertion
- type Config
- type CookieSessionStorage
- type EcdsaKey
- type HeaderConfig
- type JwksHandler
- type JwksKey
- type JwksKeys
- type OidcDiscovery
- type OidcEndpoints
- type OidcIntrospectionResponse
- type OidcState
- type OidcTokenResponse
- type ProviderConfig
- type RsaKey
- type SessionCookieConfig
- type SessionState
- type SessionStorage
- type TraefikOidcAuth
Constants ¶
View Source
const ( LogLevelDebug string = "DEBUG" LogLevelInfo string = "INFO" LogLevelWarn string = "WARN" LogLevelError string = "ERROR" )
View Source
const DefaultSecret = "MLFs4TT99kOOq8h3UAVRtYoCTDYXiRcZ"
Variables ¶
View Source
var LogLevels = map[string]int{ LogLevelError: 1, LogLevelWarn: 2, LogLevelInfo: 3, LogLevelDebug: 4, }
Functions ¶
func ChunkString ¶
func GenerateSessionId ¶
func GenerateSessionId() string
Types ¶
type AuthorizationConfig ¶
type AuthorizationConfig struct {
AssertClaims []ClaimAssertion `json:"assert_claims"`
}
type AuthorizationCookieConfig ¶
type AuthorizationCookieConfig struct {
Name string `json:"name"`
}
type AuthorizationHeaderConfig ¶
type AuthorizationHeaderConfig struct {
Name string `json:"name"`
}
type ClaimAssertion ¶
type Config ¶
type Config struct {
LogLevel string `json:"log_level"`
Secret string `json:"secret"`
Provider *ProviderConfig `json:"provider"`
Scopes []string `json:"scopes"`
// Can be a relative path or a full URL.
// If a relative path is used, the scheme and domain will be taken from the incoming request.
// In this case, the callback path will overlay all hostnames behind the middleware.
// If a full URL is used, all callbacks are sent there. It is the user's responsibility to ensure
// that the callback URL is also routed to this middleware plugin.
CallbackUri string `json:"callback_uri"`
// The URL used to start authorization when needed.
// All other requests that are not already authorized will return a 401 Unauthorized.
// When left empty, all requests can start authorization.
LoginUri string `json:"login_uri"`
PostLoginRedirectUri string `json:"post_login_redirect_uri"`
LogoutUri string `json:"logout_uri"`
PostLogoutRedirectUri string `json:"post_logout_redirect_uri"`
CookieNamePrefix string `json:"cookie_name_prefix"`
SessionCookie *SessionCookieConfig `json:"session_cookie"`
AuthorizationHeader *AuthorizationHeaderConfig `json:"authorization_header"`
AuthorizationCookie *AuthorizationCookieConfig `json:"authorization_cookie"`
Authorization *AuthorizationConfig `json:"authorization"`
Headers []HeaderConfig `json:"headers"`
}
type CookieSessionStorage ¶
type CookieSessionStorage struct {
}
func CreateCookieSessionStorage ¶
func CreateCookieSessionStorage() *CookieSessionStorage
func (*CookieSessionStorage) StoreSession ¶
func (storage *CookieSessionStorage) StoreSession(sessionId string, state *SessionState) (string, error)
func (*CookieSessionStorage) TryGetSession ¶
func (storage *CookieSessionStorage) TryGetSession(sessionTicket string) (*SessionState, error)
type HeaderConfig ¶
type JwksHandler ¶
type JwksHandler struct {
Url string
RsaKeys []*RsaKey
EcdsaKeys []*EcdsaKey
CacheDate time.Time
Lock sync.RWMutex
}
func (*JwksHandler) EnsureLoaded ¶
func (h *JwksHandler) EnsureLoaded(oidcAuth *TraefikOidcAuth, forceReload bool) error
type OidcDiscovery ¶
type OidcDiscovery struct {
AcrValuesSupported []string `json:"acr_values_supported"`
AuthorizationEncryptionAlgValuesSupported []string `json:"authorization_encryption_alg_values_supported"`
AuthorizationEncryptionEncValuesSupported []string `json:"authorization_encryption_enc_values_supported"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
AuthorizationSigningAlgValuesSupported []string `json:"authorization_signing_alg_values_supported"`
BackchannelAuthenticationEndpoint string `json:"backchannel_authentication_endpoint"`
BackchannelAuthenticationRequestSigningAlgValuesSupported []string `json:"backchannel_authentication_request_signing_alg_values_supported"`
BackchannelLogoutSessionSupported bool `json:"backchannel_logout_session_supported"`
BackchannelLogoutSupported bool `json:"backchannel_logout_supported"`
BackchannelTokenDeliveryModesSupported []string `json:"backchannel_token_delivery_modes_supported"`
CheckSessionIframe string `json:"check_session_iframe"`
ClaimsParameterSupported bool `json:"claims_parameter_supported"`
ClaimsSupported []string `json:"claims_supported"`
ClaimTypesSupported []string `json:"claim_types_supported"`
CloudGraphHostName string `json:"cloud_graph_host_name"`
CloudInstanceName string `json:"cloud_instance_name"`
CodeChallengeMethodsSupported []string `json:"code_challenge_methods_supported"`
DeviceAuthorizationEndpoint string `json:"device_authorization_endpoint"`
DisplayValuesSupported []string `json:"display_values_supported"`
EndSessionEndpoint string `json:"end_session_endpoint"`
FrontchannelLogoutSessionSupported bool `json:"frontchannel_logout_session_supported"`
FrontchannelLogoutSupported bool `json:"frontchannel_logout_supported"`
GrantTypesSupported []string `json:"grant_types_supported"`
HttpLogoutSupported bool `json:"http_logout_supported"`
IdTokenEncryptionAlgValuesSupported []string `json:"id_token_encryption_alg_values_supported"`
IdTokenEncryptionEncValuesSupported []string `json:"id_token_encryption_enc_values_supported"`
IdTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported"`
IntrospectionEndpoint string `json:"introspection_endpoint"`
IntrospectionEndpointAuthMethodsSupported []string `json:"introspection_endpoint_auth_methods_supported"`
IntrospectionEndpointAuthSigningAlgValuesSupported []string `json:"introspection_endpoint_auth_signing_alg_values_supported"`
Issuer string `json:"issuer"`
JWKSURI string `json:"jwks_uri"`
KerberosEndpoint string `json:"kerberos_endpoint"`
MicrosoftGraphHost string `json:"msgraph_host"`
MtlsEndpointAliases *OidcEndpoints `json:"mtls_endpoint_aliases"`
PushedAuthorizationRequestEndpoint string `json:"pushed_authorization_request_endpoint"`
RbacURL string `json:"rbac_url"`
RegistrationEndpoint string `json:"registration_endpoint"`
RequestObjectEncryptionAlgValuesSupported []string `json:"request_object_encryption_alg_values_supported"`
RequestObjectEncryptionEncValuesSupported []string `json:"request_object_encryption_enc_values_supported"`
RequestObjectSigningAlgValuesSupported []string `json:"request_object_signing_alg_values_supported"`
RequestParameterSupported bool `json:"request_parameter_supported"`
RequestURIParameterSupported bool `json:"request_uri_parameter_supported"`
RequirePushedAuthorizationRequests bool `json:"require_pushed_authorization_requests"`
RequireRequestUriRegistration bool `json:"require_request_uri_registration"`
ResponseModesSupported []string `json:"response_modes_supported"`
ResponseTypesSupported []string `json:"response_types_supported"`
RevocationEndpoint string `json:"revocation_endpoint"`
RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported"`
RevocationEndpointAuthSigningAlgValuesSupported []string `json:"revocation_endpoint_auth_signing_alg_values_supported"`
ScopesSupported []string `json:"scopes_supported"`
SubjectTypesSupported []string `json:"subject_types_supported"`
TenantRegionScope string `json:"tenant_region_scope"`
TlsClientCertificateBoundAccessTokens bool `json:"tls_client_certificate_bound_access_tokens"`
TokenEndpoint string `json:"token_endpoint"`
TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported"`
TokenEndpointAuthSigningAlgValuesSupported []string `json:"token_endpoint_auth_signing_alg_values_supported"`
TokenRevocationEndpoint string `json:"token_revocation_endpoint"`
UserinfoEncryptionAlgValuesSupported []string `json:"userinfo_encryption_alg_values_supported"`
UserinfoEncryptionEncValuesSupported []string `json:"userinfo_encryption_enc_values_supported"`
UserinfoEndpoint string `json:"userinfo_endpoint"`
UserinfoSigningAlgValuesSupported []string `json:"userinfo_signing_alg_values_supported"`
}
OidcDiscovery represents the discovered OIDC endpoints
func GetOidcDiscovery ¶
type OidcEndpoints ¶
type OidcEndpoints struct {
AuthorizationEndpoint string `json:"authorization_endpoint"`
BackchannelAuthenticationEndpoint string `json:"backchannel_authentication_endpoint"`
DeviceAuthorizationEndpoint string `json:"device_authorization_endpoint"`
EndSessionEndpoint string `json:"end_session_endpoint"`
IntrospectionEndpoint string `json:"introspection_endpoint"`
KerberosEndpoint string `json:"kerberos_endpoint"`
PushedAuthorizationRequestEndpoint string `json:"pushed_authorization_request_endpoint"`
RegistrationEndpoint string `json:"registration_endpoint"`
RevocationEndpoint string `json:"revocation_endpoint"`
TokenEndpoint string `json:"token_endpoint"`
TokenRevocationEndpoint string `json:"token_revocation_endpoint"`
UserinfoEndpoint string `json:"userinfo_endpoint"`
}
type OidcIntrospectionResponse ¶
type OidcIntrospectionResponse struct {
Active bool `json:"active"`
}
type OidcTokenResponse ¶
type ProviderConfig ¶
type ProviderConfig struct {
Url string `json:"url"`
UrlEnv string `json:"url_env"`
InsecureSkipVerify bool `json:"insecure_skip_verify"`
CABundle string `json:"ca_bundle"`
CABundleFile string `json:"ca_bundle_file"`
CABundleFileEnv string `json:"ca_bundle_file_env"`
ClientId string `json:"client_id"`
ClientIdEnv string `json:"client_id_env"`
ClientSecret string `json:"client_secret"`
ClientSecretEnv string `json:"client_secret_env"`
UsePkce bool `json:"use_pkce"`
ValidateAudience bool `json:"validate_audience"`
ValidAudience string `json:"valid_audience"`
ValidAudienceEnv string `json:"valid_audience_env"`
ValidateIssuer bool `json:"validate_issuer"`
ValidIssuer string `json:"valid_issuer"`
ValidIssuerEnv string `json:"valid_issuer_env"`
// AccessToken or IdToken or Introspection
TokenValidation string `json:"verification_token"`
}
type SessionCookieConfig ¶
type SessionState ¶
type SessionStorage ¶
type SessionStorage interface {
StoreSession(sessionId string, state *SessionState) (string, error)
TryGetSession(sessionTicket string) (*SessionState, error)
}
type TraefikOidcAuth ¶
type TraefikOidcAuth struct {
ProviderURL *url.URL
CallbackURL *url.URL
Config *Config
SessionStorage SessionStorage
DiscoveryDocument *OidcDiscovery
Jwks *JwksHandler
Lock sync.RWMutex
// contains filtered or unexported fields
}
func (*TraefikOidcAuth) EnsureOidcDiscovery ¶
func (toa *TraefikOidcAuth) EnsureOidcDiscovery() error
Make sure we fetch oidc discovery document during first request - avoid race condition Perform lock when changing document - we are in concurrent environment
func (*TraefikOidcAuth) GetAbsoluteCallbackURL ¶
func (toa *TraefikOidcAuth) GetAbsoluteCallbackURL(req *http.Request) *url.URL
func (*TraefikOidcAuth) ServeHTTP ¶
func (toa *TraefikOidcAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request)
Click to show internal directories.
Click to hide internal directories.