{"id":34509838,"url":"https://github.com/bjornmelin/oidc-jwt-verifier","last_synced_at":"2026-04-07T01:01:44.884Z","repository":{"id":329233198,"uuid":"1118669239","full_name":"BjornMelin/oidc-jwt-verifier","owner":"BjornMelin","description":"Framework-agnostic JWT verifier for OIDC issuers with JWKS caching, strict claim validation, and scope/permission checks.","archived":false,"fork":false,"pushed_at":"2026-04-06T23:16:25.000Z","size":1348,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-06T23:21:52.917Z","etag":null,"topics":["access-token","api-security","auth0","authentication","authorization","bearer-token","json-web-token","jwks","jwt","key-rotation","oauth2","oidc","openid-connect","pyjwt","python","rfc6750","rfc8725","rfc9700"],"latest_commit_sha":null,"homepage":"http://oidc-jwt-verifier.bjornmelin.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BjornMelin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"docs/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-12-18T05:28:30.000Z","updated_at":"2026-04-06T23:15:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/BjornMelin/oidc-jwt-verifier","commit_stats":null,"previous_names":["bjornmelin/oidc-jwt-verifier"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/BjornMelin/oidc-jwt-verifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BjornMelin%2Foidc-jwt-verifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BjornMelin%2Foidc-jwt-verifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BjornMelin%2Foidc-jwt-verifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BjornMelin%2Foidc-jwt-verifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BjornMelin","download_url":"https://codeload.github.com/BjornMelin/oidc-jwt-verifier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BjornMelin%2Foidc-jwt-verifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31495466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T17:22:55.647Z","status":"ssl_error","status_checked_at":"2026-04-06T17:22:54.741Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["access-token","api-security","auth0","authentication","authorization","bearer-token","json-web-token","jwks","jwt","key-rotation","oauth2","oidc","openid-connect","pyjwt","python","rfc6750","rfc8725","rfc9700"],"created_at":"2025-12-24T03:39:00.421Z","updated_at":"2026-04-07T01:01:44.821Z","avatar_url":"https://github.com/BjornMelin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oidc-jwt-verifier\n\n[![Release](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FBjornMelin%2Foidc-jwt-verifier%2Fmain%2F.release-please-manifest.json\u0026query=%24%5B%22.%22%5D\u0026label=release\u0026style=flat-square\u0026cacheSeconds=60)](https://github.com/BjornMelin/oidc-jwt-verifier/releases)\n[![PyPI](https://img.shields.io/pypi/v/oidc-jwt-verifier?label=pypi\u0026style=flat-square)](https://pypi.org/project/oidc-jwt-verifier/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/oidc-jwt-verifier?style=flat-square)](https://pypi.org/project/oidc-jwt-verifier/)\n[![Tests](https://img.shields.io/github/actions/workflow/status/BjornMelin/oidc-jwt-verifier/ci.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/BjornMelin/oidc-jwt-verifier/actions/workflows/ci.yml)\n[![Coverage](https://img.shields.io/codecov/c/github/BjornMelin/oidc-jwt-verifier?branch=main\u0026style=flat-square)](https://codecov.io/gh/BjornMelin/oidc-jwt-verifier)\n[![Docs](https://img.shields.io/badge/docs-live-blue?style=flat-square)](https://oidc-jwt-verifier.bjornmelin.io/)\n[![License](https://img.shields.io/github/license/BjornMelin/oidc-jwt-verifier?style=flat-square)](https://github.com/BjornMelin/oidc-jwt-verifier/blob/main/LICENSE)\n\n`oidc-jwt-verifier` is a small, framework-agnostic JWT verification core for OIDC/JWKS issuers.\n\nIt provides:\n\n- A hardened sync verifier (`JWTVerifier`)\n- A native async verifier (`AsyncJWTVerifier`)\n- Public JWKS lifecycle/readiness APIs on both sync and async clients\n- First-party FastAPI and Starlette integration helpers\n\n## Install\n\n```bash\npip install oidc-jwt-verifier\n```\n\nFor async/FastAPI/Starlette support:\n\n```bash\npip install \"oidc-jwt-verifier[async]\"\npip install \"oidc-jwt-verifier[fastapi]\"\npip install \"oidc-jwt-verifier[starlette]\"\n```\n\nFor development:\n\n```bash\nuv pip install -e \".[dev]\"\n```\n\n## Quickstart\n\n```python\nfrom oidc_jwt_verifier import AuthConfig, JWTVerifier\n\nconfig = AuthConfig(\n    issuer=\"https://example-issuer/\",\n    audience=\"https://example-api\",\n    jwks_url=\"https://example-issuer/.well-known/jwks.json\",\n    allowed_algs=(\"RS256\",),\n    required_scopes=(\"read:users\",),\n)\n\nverifier = JWTVerifier(config)\nclaims = verifier.verify_access_token(token)\n```\n\n## Async quickstart\n\n```python\nfrom oidc_jwt_verifier import AuthConfig\nfrom oidc_jwt_verifier.async_verifier import AsyncJWTVerifier\n\nconfig = AuthConfig(\n    issuer=\"https://example-issuer/\",\n    audience=\"https://example-api\",\n    jwks_url=\"https://example-issuer/.well-known/jwks.json\",\n    allowed_algs=(\"RS256\",),\n)\n\nasync def verify(token: str) -\u003e dict[str, object]:\n    async with AsyncJWTVerifier(config) as verifier:\n        return await verifier.verify_access_token(token)\n```\n\n## JWKS lifecycle and readiness\n\nUse the verifier-level helpers for startup validation and cache priming:\n\n```python\nfrom oidc_jwt_verifier import AuthConfig, JWTVerifier\n\nconfig = AuthConfig(\n    issuer=\"https://example-issuer/\",\n    audience=\"https://example-api\",\n    jwks_url=\"https://example-issuer/.well-known/jwks.json\",\n)\n\nverifier = JWTVerifier(config)\nif not verifier.healthcheck(refresh=True):\n    raise RuntimeError(\"JWKS endpoint is not ready\")\n\nsigning_keys = verifier.get_signing_keys()\n```\n\nIf you need direct client access, use `JWKSClient` or `AsyncJWKSClient` from\n`oidc_jwt_verifier.jwks` and `oidc_jwt_verifier.async_jwks`. The sync and async\nlifecycle/readiness APIs are intentionally parallel public surfaces.\n\nThese are startup/readiness APIs. Do not call them on every request.\n\n## FastAPI integration\n\n```python\nfrom fastapi import Depends, FastAPI\nfrom oidc_jwt_verifier import AuthConfig\nfrom oidc_jwt_verifier.async_verifier import AsyncJWTVerifier\nfrom oidc_jwt_verifier.integrations.fastapi import create_async_bearer_dependency\n\napp = FastAPI()\nverifier = AsyncJWTVerifier(\n    AuthConfig(\n        issuer=\"https://example-issuer/\",\n        audience=\"https://example-api\",\n        jwks_url=\"https://example-issuer/.well-known/jwks.json\",\n    )\n)\nauth = create_async_bearer_dependency(verifier, realm=\"api\")\n\n@app.get(\"/protected\")\nasync def protected(claims: dict = Depends(auth)):\n    return {\"sub\": claims.get(\"sub\")}\n```\n\n## Starlette integration\n\n```python\nfrom starlette.applications import Starlette\nfrom starlette.requests import Request\nfrom starlette.responses import JSONResponse\nfrom starlette.routing import Route\n\nfrom oidc_jwt_verifier.integrations.starlette import BearerAuthMiddleware\n\nasync def protected(request: Request) -\u003e JSONResponse:\n    claims = request.state.auth_claims\n    return JSONResponse({\"sub\": claims.get(\"sub\")})\n\napp = Starlette(routes=[Route(\"/protected\", protected)])\napp.add_middleware(BearerAuthMiddleware, verifier=verifier, realm=\"api\")\n```\n\n## Secure-by-default behavior\n\nThe verifier:\n\n- Verifies signature, `iss`, `aud`, `exp`, and `nbf` (when present).\n- Uses an explicit algorithm allowlist and rejects `alg=none`.\n- Enforces minimum cryptographic key lengths by default (configurable via `enforce_minimum_key_length`).\n- Fails closed on malformed tokens, JWKS fetch errors, timeouts, missing keys, and missing `kid`.\n- Never derives a JWKS URL from token headers, and rejects tokens that include `jku`, `x5u`, or `crit`.\n- Supports Auth0-style multi-audience tokens (`aud` as an array) and enforces required scopes and\n  permissions.\n\nAuth0 guidance for API token validation calls out validating the JWT and then checking `aud` and\nscopes in the `scope` claim. See the Auth0 docs for details.\n\n## Error handling\n\nThe public exception type is `AuthError`.\n\n`AuthError` carries:\n\n- `code`: stable, machine-readable reason\n- `status_code`: `401` (authentication) or `403` (authorization)\n- `www_authenticate_header()`: an RFC 6750 compatible `WWW-Authenticate` value for Bearer auth\n\n```python\nfrom oidc_jwt_verifier import AuthError\n\ntry:\n    claims = verifier.verify_access_token(token)\nexcept AuthError as err:\n    status = err.status_code\n    www_authenticate = err.www_authenticate_header()\n```\n\n## Why this library\n\nJWT verification for APIs is easy to get mostly right while still missing important security and\ninteroperability details. This library is a small, framework-agnostic core that centralizes\nconservative verification policy (claims, algorithms, header handling) and authorization checks\n(scopes/permissions) so you can reuse it across projects.\n\nFor comparisons against common alternatives (PyJWT directly, discovery-driven verifiers, framework\nintegrations), see `docs/alternatives.md`.\n\n## Documentation\n\nPrimary docs are built with MkDocs in `docs/`.\n\n- Getting started: `docs/getting-started.md`\n- Sync usage: `docs/usage/sync.md`\n- Async usage: `docs/usage/async.md`\n- FastAPI integration: `docs/integrations/fastapi.md`\n- Starlette integration: `docs/integrations/starlette.md`\n- Configuration and security: `docs/configuration.md`, `docs/security.md`\n- API reference: `docs/reference.md`\n- Migration guidance: `docs/migration.md`\n\n## Contributing\n\nUse [Conventional Commits](https://www.conventionalcommits.org/).  \nRelease-specific commit guidance for maintainers is documented in `AGENTS.md`.\n\n## References\n\n- Auth0: Validate Access Tokens: `https://auth0.com/docs/secure/tokens/access-tokens/validate-access-tokens`\n- Auth0: Validate JSON Web Tokens: `https://auth0.com/docs/secure/tokens/json-web-tokens/validate-json-web-tokens`\n- RFC 8725: JSON Web Token Best Current Practices: `https://datatracker.ietf.org/doc/html/rfc8725`\n- RFC 9700: Best Current Practice for OAuth 2.0 Security: `https://www.rfc-editor.org/info/rfc9700`\n- PyJWT docs and examples: `https://pyjwt.readthedocs.io/en/stable/usage.html`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjornmelin%2Foidc-jwt-verifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjornmelin%2Foidc-jwt-verifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjornmelin%2Foidc-jwt-verifier/lists"}