Documentation
¶
Index ¶
- Variables
- func AuthorizationMiddleware(staticConfig *config.StaticConfig, oidcProvider *oidc.Provider, ...) func(http.Handler) http.Handler
- func RequestMiddleware(next http.Handler) http.Handler
- func Serve(ctx context.Context, mcpServer *mcp.Server, staticConfig *config.StaticConfig, ...) error
- func WellKnownHandler(staticConfig *config.StaticConfig) http.Handler
- type JWTClaims
- func (c *JWTClaims) GetScopes() []string
- func (c *JWTClaims) ValidateOffline(audience string) error
- func (c *JWTClaims) ValidateWithKubernetesApi(ctx context.Context, audience string, verifier KubernetesApiTokenVerifier) error
- func (c *JWTClaims) ValidateWithProvider(ctx context.Context, audience string, provider *oidc.Provider) error
- type KubernetesApiTokenVerifier
- type SecurityTokenService
- type WellKnown
Constants ¶
This section is empty.
Variables ¶
View Source
var WellKnownEndpoints = []string{
oauthAuthorizationServerEndpoint,
oauthProtectedResourceEndpoint,
openIDConfigurationEndpoint,
}
Functions ¶
func AuthorizationMiddleware ¶
func AuthorizationMiddleware(staticConfig *config.StaticConfig, oidcProvider *oidc.Provider, verifier KubernetesApiTokenVerifier) func(http.Handler) http.Handler
AuthorizationMiddleware validates the OAuth flow for protected resources.
The flow is skipped for unprotected resources, such as health checks and well-known endpoints.
There are several auth scenarios supported by this middleware: 1. requireOAuth is false: - The OAuth flow is skipped, and the server is effectively unprotected. - The request is passed to the next handler without any validation. see TestAuthorizationRequireOAuthFalse 2. requireOAuth is set to true, server is protected: 2.1. Raw Token Validation (oidcProvider is nil): - The token is validated offline for basic sanity checks (expiration). - If OAuthAudience is set, the token is validated against the audience. - If ValidateToken is set, the token is then used against the Kubernetes API Server for TokenReview. see TestAuthorizationRawToken 2.2. OIDC Provider Validation (oidcProvider is not nil): - The token is validated offline for basic sanity checks (audience and expiration). - If OAuthAudience is set, the token is validated against the audience. - The token is then validated against the OIDC Provider. - If ValidateToken is set, the token is then used against the Kubernetes API Server for TokenReview. see TestAuthorizationOidcToken 2.3. OIDC Token Exchange (oidcProvider is not nil, StsClientId and StsAudience are set): - The token is validated offline for basic sanity checks (audience and expiration). - If OAuthAudience is set, the token is validated against the audience. - The token is then validated against the OIDC Provider. - If the token is valid, an external account token exchange is performed using the OIDC Provider to obtain a new token with the specified audience and scopes. - If ValidateToken is set, the exchanged token is then used against the Kubernetes API Server for TokenReview. see TestAuthorizationOidcTokenExchange
func WellKnownHandler ¶ added in v0.0.49
func WellKnownHandler(staticConfig *config.StaticConfig) http.Handler
Types ¶
type JWTClaims ¶
func ParseJWTClaims ¶
func (*JWTClaims) ValidateOffline ¶ added in v0.0.49
ValidateOffline Checks if the JWT claims are valid and if the audience matches the expected one.
func (*JWTClaims) ValidateWithKubernetesApi ¶ added in v0.0.49
type KubernetesApiTokenVerifier ¶ added in v0.0.49
type SecurityTokenService ¶ added in v0.0.49
type SecurityTokenService struct { *oidc.Provider ClientId string ClientSecret string ExternalAccountAudience string ExternalAccountScopes []string }
func NewFromConfig ¶ added in v0.0.49
func NewFromConfig(config *config.StaticConfig, provider *oidc.Provider) *SecurityTokenService
func (*SecurityTokenService) ExternalAccountTokenExchange ¶ added in v0.0.49
func (*SecurityTokenService) IsEnabled ¶ added in v0.0.49
func (sts *SecurityTokenService) IsEnabled() bool
Click to show internal directories.
Click to hide internal directories.