{"id":15887824,"url":"https://github.com/iwpnd/fastapi-key-auth","last_synced_at":"2025-04-06T09:07:36.945Z","repository":{"id":36973270,"uuid":"360241924","full_name":"iwpnd/fastapi-key-auth","owner":"iwpnd","description":"FastAPI API key authorizer","archived":false,"fork":false,"pushed_at":"2025-03-24T09:26:13.000Z","size":1033,"stargazers_count":37,"open_issues_count":0,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-30T07:11:12.490Z","etag":null,"topics":["fastapi","fastapi-middleware","fastapi-security","middleware"],"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/iwpnd.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-21T16:48:39.000Z","updated_at":"2025-03-24T09:26:09.000Z","dependencies_parsed_at":"2023-11-06T09:29:50.686Z","dependency_job_id":"c495f6b0-d673-4d45-8831-3d2f37889b70","html_url":"https://github.com/iwpnd/fastapi-key-auth","commit_stats":{"total_commits":226,"total_committers":7,"mean_commits":"32.285714285714285","dds":"0.26106194690265483","last_synced_commit":"20d76067b9c265048eaed81ce2e572f8202aaf2d"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwpnd%2Ffastapi-key-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwpnd%2Ffastapi-key-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwpnd%2Ffastapi-key-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwpnd%2Ffastapi-key-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iwpnd","download_url":"https://codeload.github.com/iwpnd/fastapi-key-auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457800,"owners_count":20941906,"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","fastapi-middleware","fastapi-security","middleware"],"created_at":"2024-10-06T06:05:04.600Z","updated_at":"2025-04-06T09:07:36.925Z","avatar_url":"https://github.com/iwpnd.png","language":"Python","readme":"\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n  \u003ch3 align=\"center\"\u003eFastAPI-key-auth\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    Secure your FastAPI endpoints using API keys.\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/iwpnd/fastapi-key-auth/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/iwpnd/fastapi-key-auth/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails open=\"open\"\u003e\n  \u003csummary\u003e\u003ch2 style=\"display: inline-block\"\u003eTable of Contents\u003c/h2\u003e\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n\n## About The Project\n\nOn deployment inject API keys authorized to use your service. Every call to a private\nendpoint of your service has to include a `header['x-api-key']` attribute that is\nvalidated against the API keys in your environment.\nIf it is present, a request is authorized. If it is not FastAPI return `401 Unauthorized`.\nUse this either as a middleware, or as Dependency.\n\n### Built With\n\n-   [starlette](https://github.com/encode/starlette)\n-   [fastapi](https://github.com/tiangolo/fastapi)\n\n\u003c!-- GETTING STARTED --\u003e\n\n## Getting Started\n\n### Installation\n\n1. Clone and install\n    ```sh\n    git clone https://github.com/iwpnd/fastapi-key-auth.git\n    poetry install\n    ```\n2. Install with pip\n    ```sh\n    pip install fastapi-key-auth\n    ```\n3. Install with poetry\n    ```sh\n    poetry add fastapi-key-auth\n    ```\n\n## Usage\n\nAs Middleware:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_key_auth import AuthorizerMiddleware\n\napp = FastAPI()\n\napp.add_middleware(AuthorizerMiddleware, public_paths=[\"/ping\"], key_pattern=\"API_KEY_\")\n\n# optional use regex startswith\napp.add_middleware(AuthorizerMiddleware, public_paths=[\"/ping\", \"^/users\"])\n```\n\nAs Dependency\n\n```python\nfrom fastapi import FastAPI, Depends\nfrom fastapi_key_auth import AuthorizerDependency\n\nauthorizer = AuthorizerDependency(key_pattern=\"API_KEY_\")\n\n# either globally or in a router\napp = FastAPI(dependencies=[Depends(authorizer)])\n```\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n\u003c!-- CONTACT --\u003e\n\n## Contact\n\nBenjamin Ramser - [@imwithpanda](https://twitter.com/imwithpanda) - ahoi@iwpnd.pw  \nProject Link: [https://github.com/iwpnd/fastapi-key-auth](https://github.com/iwpnd/fastapi-key-auth)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwpnd%2Ffastapi-key-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiwpnd%2Ffastapi-key-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwpnd%2Ffastapi-key-auth/lists"}