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, httpClient *http.Client) http.Handler
- type JWTClaims
- 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) 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.
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.
see TestAuthorizationOidcToken
func RequestMiddleware ¶
RequestMiddleware creates OpenTelemetry spans for HTTP requests.
func WellKnownHandler ¶ added in v0.0.49
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.
Click to show internal directories.
Click to hide internal directories.