{"id":20374514,"url":"https://github.com/lucasrcezimbra/ninja-api-key","last_synced_at":"2025-04-12T07:12:39.133Z","repository":{"id":238854445,"uuid":"797761714","full_name":"lucasrcezimbra/ninja-api-key","owner":"lucasrcezimbra","description":"API Key authentication for Django Ninja","archived":false,"fork":false,"pushed_at":"2025-04-07T20:55:39.000Z","size":77,"stargazers_count":11,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T07:12:33.638Z","etag":null,"topics":["api","api-key","api-key-authentication","apikey","apikey-authentication","django","django-ninja","ninja","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/ninja-api-key/","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/lucasrcezimbra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-08T13:16:59.000Z","updated_at":"2025-04-07T20:55:41.000Z","dependencies_parsed_at":"2024-10-25T03:19:07.486Z","dependency_job_id":"af25836f-db2d-4cae-ac54-4893abff7c95","html_url":"https://github.com/lucasrcezimbra/ninja-api-key","commit_stats":null,"previous_names":["lucasrcezimbra/ninja-api-key"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasrcezimbra%2Fninja-api-key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasrcezimbra%2Fninja-api-key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasrcezimbra%2Fninja-api-key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasrcezimbra%2Fninja-api-key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucasrcezimbra","download_url":"https://codeload.github.com/lucasrcezimbra/ninja-api-key/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530571,"owners_count":21119600,"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":["api","api-key","api-key-authentication","apikey","apikey-authentication","django","django-ninja","ninja","python"],"created_at":"2024-11-15T01:24:52.398Z","updated_at":"2025-04-12T07:12:39.092Z","avatar_url":"https://github.com/lucasrcezimbra.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ninja API Key\n\n\n[![PyPI](https://img.shields.io/pypi/v/ninja-api-key.svg)](https://pypi.python.org/pypi/ninja-api-key)\n\n[![codecov](https://codecov.io/gh/lucasrcezimbra/ninja-api-key/graph/badge.svg)](https://codecov.io/gh/lucasrcezimbra/ninja-api-key)\n\n\nAPI Key authentication for [Django Ninja](https://django-ninja.dev/).\n\nThis is a fork from [django-ninja-apikey](https://github.com/mawassk/django-ninja-apikey).\n\nKey Features:\n- Easy integration into your projects\n- Well integrated with the Admin interface\n- Secure API keys due to hashing\n- Works with the standard user model\n\n\n## Installation\n\n```bash\npip install ninja-api-key\n```\n\n\n## How to use\n1. Add `ninja_apikey` to your installed apps in your Django project:\n```Python\n# settings.py\n\nINSTALLED_APPS = [\n    # ...\n    \"ninja_apikey\",\n]\n```\n\n2. Apply migrations\n```shell\npython manage.py migrate\n```\n\n3. Secure\n\n    a. the whole API\n    ```Python\n    # api.py\n\n    from ninja import NinjaAPI\n    from ninja_apikey.security import APIKeyAuth\n\n    #  ...\n\n    api = NinjaAPI(auth=APIKeyAuth())\n\n    # ...\n\n    @api.get(\"/secure_endpoint\")\n    def secure_endpoint(request):\n        return f\"Hello, {request.user}!\"\n    ```\n\n    b. an specific endpoint\n    ```Python\n    # api.py\n\n    from ninja import NinjaAPI\n    from ninja_apikey.security import APIKeyAuth\n\n    #  ...\n\n    auth = APIKeyAuth()\n    api = NinjaAPI()\n\n    # ...\n\n    @api.get(\"/secure_endpoint\", auth=auth)\n    def secure_endpoint(request):\n        return f\"Hello, {request.user}!\"\n    ```\n\n\n4. ninja-api-key uses `settings.PASSWORD_HASHERS` to hash the API keys.\n   Django's default `PBKDF2PasswordHasher` may be slow depending on the number\n   of iterations. You can change the `settings.PASSWORD_HASHERS` to\n   use a faster (but less secure) one. ninja-api-key provides a `SHA256PasswordHasher`.\n\n   ```python\n    # settings.py\n\n    PASSWORD_HASHERS = [\n        \"ninja_apikey.hashers.SHA256PasswordHasher\",\n        # others\n    ]\n    ```\n\n    ⚠️ Keep in mind that this will affect Django authentication as a whole,\n       not just ninja-api-key.\n\n\n## Contributing\n\nContributions are welcome; feel free to open an Issue or Pull Request.\n\n```\ngit clone https://github.com/lucasrcezimbra/ninja-api-key\ncd ninja-api-key\npython -m venv .venv\nsource .venv/bin/activate\npip install .[test]\npre-commit install\nmake test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucasrcezimbra%2Fninja-api-key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucasrcezimbra%2Fninja-api-key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucasrcezimbra%2Fninja-api-key/lists"}