{"id":19805355,"url":"https://github.com/harrymwinters/fastapi-oidc","last_synced_at":"2025-04-12T18:54:27.819Z","repository":{"id":39824498,"uuid":"289590381","full_name":"HarryMWinters/fastapi-oidc","owner":"HarryMWinters","description":"Verify and decrypt 3rd party OIDC ID tokens to protect your fastapi (https://github.com/tiangolo/fastapi) endpoints.","archived":false,"fork":false,"pushed_at":"2025-02-11T19:03:28.000Z","size":338,"stargazers_count":79,"open_issues_count":11,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T11:55:19.177Z","etag":null,"topics":["fastapi","oidc","oidc-resource-server"],"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/HarryMWinters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2020-08-23T00:42:10.000Z","updated_at":"2025-03-29T02:48:21.000Z","dependencies_parsed_at":"2024-09-05T19:12:06.520Z","dependency_job_id":"9fcdef25-6366-4ce4-9fb1-15b2adbdf14c","html_url":"https://github.com/HarryMWinters/fastapi-oidc","commit_stats":{"total_commits":22,"total_committers":3,"mean_commits":7.333333333333333,"dds":0.09090909090909094,"last_synced_commit":"186ca59dcae7a0ed6de18428cb4a606fe6a33750"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryMWinters%2Ffastapi-oidc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryMWinters%2Ffastapi-oidc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryMWinters%2Ffastapi-oidc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryMWinters%2Ffastapi-oidc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HarryMWinters","download_url":"https://codeload.github.com/HarryMWinters/fastapi-oidc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618262,"owners_count":21134200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","oidc","oidc-resource-server"],"created_at":"2024-11-12T09:03:33.901Z","updated_at":"2025-04-12T18:54:27.788Z","avatar_url":"https://github.com/HarryMWinters.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI OIDC\n\n\u003cp align=\"left\"\u003e\n    \u003ca href=\"https://github.com/HarryMWinters/fastapi-oidc/actions?query=workflow%3ATest\"\n       target=\"_blank\"\u003e\n       \u003cimg src=\"https://github.com/HarryMWinters/fastapi-oidc/workflows/Test/badge.svg\"  \n            alt=\"Test\"\u003e\n    \u003c/a\u003e\n    \u003ca href='https://fastapi-oidc.readthedocs.io/en/latest/?badge=latest'\u003e\n        \u003cimg src='https://readthedocs.org/projects/fastapi-oidc/badge/?version=latest' alt='Documentation Status' /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/fastapi-oidc\" \n       target=\"_blank\"\u003e\n       \u003cimg src=\"https://img.shields.io/pypi/v/fastapi-oidc?color=%2334D058\u0026label=pypi%20package\" \n            alt=\"Package version\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n:warning: **See [this issue](https://github.com/HarryMWinters/fastapi-oidc/issues/1) for\nsimple role-your-own example of checking OIDC tokens.**\n\nVerify and decrypt 3rd party OIDC ID tokens to protect your\n[fastapi](https://github.com/tiangolo/fastapi) endpoints.\n\n**Documentation:** [ReadTheDocs](https://fastapi-oidc.readthedocs.io/en/latest/)\n\n**Source code:** [Github](https://github.com/HarryMWinters/fastapi-oidc)\n\n## Installation\n\n`pip install fastapi-oidc`\n\n## Usage\n\n### Verify ID Tokens Issued by Third Party\n\nThis is great if you just want to use something like Okta or google to handle\nyour auth. All you need to do is verify the token and then you can extract user ID info\nfrom it.\n\n```python3\nfrom fastapi import Depends\nfrom fastapi import FastAPI\n\n# Set up our OIDC\nfrom fastapi_oidc import IDToken\nfrom fastapi_oidc import get_auth\n\nOIDC_config = {\n    \"client_id\": \"0oa1e3pv9opbyq2Gm4x7\",\n    # Audience can be omitted in which case the aud value defaults to client_id\n    \"audience\": \"https://yourapi.url.com/api\",\n    \"base_authorization_server_uri\": \"https://dev-126594.okta.com\",\n    \"issuer\": \"dev-126594.okta.com\",\n    \"signature_cache_ttl\": 3600,\n}\n\nauthenticate_user: Callable = get_auth(**OIDC_config)\n\napp = FastAPI()\n\n@app.get(\"/protected\")\ndef protected(id_token: IDToken = Depends(authenticate_user)):\n    return {\"Hello\": \"World\", \"user_email\": id_token.email}\n```\n\n#### Using your own tokens\n\nThe IDToken class will accept any number of extra field but if you want to craft your\nown token class and validation that's accounted for too.\n\n```python3\nclass CustomIDToken(fastapi_oidc.IDToken):\n    custom_field: str\n    custom_default: float = 3.14\n\n\nauthenticate_user: Callable = get_auth(**OIDC_config, token_type=CustomIDToken)\n\napp = FastAPI()\n\n\n@app.get(\"/protected\")\ndef protected(id_token: CustomIDToken = Depends(authenticate_user)):\n    return {\"Hello\": \"World\", \"user_email\": id_token.custom_default}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrymwinters%2Ffastapi-oidc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharrymwinters%2Ffastapi-oidc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrymwinters%2Ffastapi-oidc/lists"}