{"id":27248829,"url":"https://github.com/bakdata/fastapi-jwks","last_synced_at":"2026-01-21T13:01:40.605Z","repository":{"id":275570460,"uuid":"797133459","full_name":"bakdata/fastapi-jwks","owner":"bakdata","description":"Validate JWTs via JWKS","archived":false,"fork":false,"pushed_at":"2025-12-01T23:42:42.000Z","size":582,"stargazers_count":3,"open_issues_count":8,"forks_count":4,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-12-03T23:42:45.820Z","etag":null,"topics":["fastapi"],"latest_commit_sha":null,"homepage":"","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/bakdata.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-07T08:59:30.000Z","updated_at":"2025-12-02T09:11:10.000Z","dependencies_parsed_at":"2025-04-10T23:48:15.790Z","dependency_job_id":"c9c094be-f356-41d0-bee1-914d2c190c2f","html_url":"https://github.com/bakdata/fastapi-jwks","commit_stats":null,"previous_names":["bakdata/fastapi-jwks"],"tags_count":9,"template":false,"template_full_name":"bakdata/template-python-poetry","purl":"pkg:github/bakdata/fastapi-jwks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakdata%2Ffastapi-jwks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakdata%2Ffastapi-jwks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakdata%2Ffastapi-jwks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakdata%2Ffastapi-jwks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bakdata","download_url":"https://codeload.github.com/bakdata/fastapi-jwks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakdata%2Ffastapi-jwks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28633747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["fastapi"],"created_at":"2025-04-10T23:48:12.343Z","updated_at":"2026-01-21T13:01:40.599Z","avatar_url":"https://github.com/bakdata.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastapi-jwks\n\nfastapi-jwks is a Python library designed to facilitate the integration of JSON Web Key Set (JWKS) with FastAPI applications. It provides a set of tools to automatically query the JWKS endpoint and verify the tokens sent over a request.\n\n## Key Features\n\n- **JWKS Endpoint Querying**: The library automatically queries the JWKS endpoint to fetch the necessary keys for token verification.\n- **Token Verification**: It verifies the tokens sent over a request with the JWKS endpoint, ensuring the authenticity and integrity of the data.\n- **Dependency Integration**: The library includes a dependency that can be easily integrated into your FastAPI application to handle token validation on every request.\n- **Pydantic Model Support**: It supports Pydantic models for token data extraction, providing a seamless way to work with the token data.\n- **Customizable State Fields**: You can customize where the payload and raw token are stored in the request state.\n- **Raw Token Access**: Access both the decoded payload and the original raw token through dependency injection.\n\n## Installation\n\n```sh\npip install fastapi_jwks\n```\n\n## Basic Usage\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi import Depends, Security\nfrom pydantic import BaseModel\nfrom fastapi_jwks.injector import JWTTokenInjector\nfrom fastapi_jwks.dependencies.jwk_auth import JWKSAuth\nfrom fastapi_jwks.models.types import JWKSConfig, JWTDecodeConfig, JWKSAuthCredentials\nfrom fastapi_jwks.validators import JWKSValidator\n\n# The data we want to extract from the token\nclass FakeToken(BaseModel):\n    user: str\n\napp = FastAPI()\n\n# Basic usage with default configuration\npayload_injector = JWTTokenInjector[FakeToken]()\n\n@app.get(\"/my-endpoint\", response_model=FakeToken)\ndef my_endpoint(fake_token: FakeToken = Depends(payload_injector)):\n    return fake_token\n\njwks_verifier = JWKSValidator[FakeToken](\n    decode_config=JWTDecodeConfig(),\n    jwks_config=JWKSConfig(url=\"http://my-fake-jwks-url/my-fake-endpoint\"),\n)\njwks_auth = JWKSAuth(jwks_validator=jwks_verifier)\n\n# global: protect all endpoints\napp = FastAPI(dependencies=[Security(jwks_auth)])\n\n# specific API router\napp.include_router(APIRouter(dependencies=[Security(jwks_auth)]))\n\n# specific route\n@app.get(\"/test\")\ndef get_test_route(credentials: Annotated[JWKSAuthCredentials[FakeToken], Security(jwks_auth)]):\n    ...\n```\n\n## Advanced Usage\n\n### Custom State Fields\n\nYou can customize where the payload and raw token are stored in the request state:\n\n```python\nfrom fastapi_jwks.models.types import JWKSAuthConfig, JWTTokenInjectorConfig\nfrom fastapi_jwks.injector import JWTTokenInjector, JWTRawTokenInjector\n\n# Configure depdency with custom field names\nauth_config = JWKSAuthConfig(\n    payload_field=\"custom_payload\",\n    token_field=\"custom_token\"\n)\njwks_auth = JWKSAuth(jwks_validator=jwks_verifier, config=auth_config)\napp = FastAPI(dependencies=[Security(jwks_auth)])\n\n# Configure injectors to use the custom fields\npayload_injector = JWTTokenInjector[FakeToken](\n    config=JWTTokenInjectorConfig(payload_field=\"custom_payload\")\n)\ntoken_injector = JWTRawTokenInjector[str](\n    config=JWTTokenInjectorConfig(token_field=\"custom_token\")\n)\n\n@app.get(\"/advanced-endpoint\")\ndef advanced_endpoint(\n    payload: FakeToken = Depends(payload_injector),\n    raw_token: str = Depends(token_injector)\n):\n    return {\n        \"user\": payload.user,\n        \"token\": raw_token\n    }\n```\n\n### Additional Configuration\n\nThe dependency also supports:\n\n- Custom authorization header name (`auth_header`)\n- Custom authorization scheme (`auth_scheme`)\n\n```python\njwks_auth = JWKSAuth(\n    jwks_validator=jwks_verifier, \n    auth_header=\"X-Custom-Auth\", \n    auth_scheme=\"Token\"\n)\napp = FastAPI(dependencies=[Security(jwks_auth)])\n```\n\n## Contributing\n\nWe are happy if you want to contribute to this project. If you find any bugs or have suggestions for improvements, please open an issue. We are also happy to accept your PRs. Just open an issue beforehand and let us know what you want to do and why.\n\n## License\n\nfastapi-jwks is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbakdata%2Ffastapi-jwks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbakdata%2Ffastapi-jwks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbakdata%2Ffastapi-jwks/lists"}