JWT validator
Provider-agnostic OIDC JWT validation. Supports RS256/384/512, PS256/384/512, ES256/384/512, EdDSA.
jwt_validator
JWKS-based JWT validation for any standard OIDC provider (Keycloak, Okta, Microsoft Entra ID, Duende, Auth0, …).
The issuer URL's /.well-known/openid-configuration is fetched once and cached; the jwks_uri within it is used to verify token signatures. No provider-specific code — pure OIDC / RFC 7517.
JwtFailReason
Bases: Enum
Why JWT validation failed — used to emit the correct WWW-Authenticate error.
validate_jwt
async
validate_jwt(
token: str, issuer_url: str
) -> tuple[dict | None, JwtFailReason | None]
Validate a signed JWT via the issuer's JWKS endpoint.
The issuer's /.well-known/openid-configuration is fetched (and cached) to locate the jwks_uri automatically — no need to hard-code a certs URL.
Returns (claims, None) on success. Returns (None, JwtFailReason.EXPIRED) when the token has expired. Returns (None, JwtFailReason.INVALID) for any other failure.
Source code in mcpauthkit/jwt_validator.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |