Name | ninja-api-key JSON |
Version |
1.0.2
JSON |
| download |
home_page | None |
Summary | Django Ninja API Key Authentication |
upload_time | 2024-10-25 10:04:14 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6.2 |
license | None |
keywords |
django
rest
ninja
auth
apikey
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Ninja API Key
[![PyPI](https://img.shields.io/pypi/v/ninja-api-key.svg)](https://pypi.python.org/pypi/ninja-api-key)
[![codecov](https://codecov.io/gh/lucasrcezimbra/ninja-api-key/graph/badge.svg)](https://codecov.io/gh/lucasrcezimbra/ninja-api-key)
API Key authentication for [Django Ninja](https://django-ninja.dev/).
This is a fork from [django-ninja-apikey](https://github.com/mawassk/django-ninja-apikey).
Key Features:
- Easy integration into your projects
- Well integrated with the Admin interface
- Secure API keys due to hashing
- Works with the standard user model
## Installation
```bash
pip install ninja-api-key
```
## How to use
1. Add `ninja_apikey` to your installed apps in your Django project:
```Python
# settings.py
INSTALLED_APPS = [
# ...
"ninja_apikey",
]
```
2. Apply migrations
```shell
python manage.py migrate
```
3. Secure
a. the whole API
```Python
# api.py
from ninja import NinjaAPI
from ninja_apikey.security import APIKeyAuth
# ...
api = NinjaAPI(auth=APIKeyAuth())
# ...
@api.get("/secure_endpoint")
def secure_endpoint(request):
return f"Hello, {request.user}!"
```
b. an specific endpoint
```Python
# api.py
from ninja import NinjaAPI
from ninja_apikey.security import APIKeyAuth
# ...
auth = APIKeyAuth()
api = NinjaAPI()
# ...
@api.get("/secure_endpoint", auth=auth)
def secure_endpoint(request):
return f"Hello, {request.user}!"
```
## Contributing
Contributions are welcome, feel free to open an Issue or Pull Request.
```
git clone https://github.com/lucasrcezimbra/ninja-api-key
cd ninja-api-key
python -m venv .venv
source .venv/bin/activate
pip install .[test]
pre-commit install
make test
```
Raw data
{
"_id": null,
"home_page": null,
"name": "ninja-api-key",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6.2",
"maintainer_email": null,
"keywords": "django, rest, ninja, auth, apikey",
"author": null,
"author_email": "Lucas Rangel Cezimbra <lucas@cezimbra.tec.br>, Maximilian Wassink <wassink.maximilian@protonmail.com>",
"download_url": "https://files.pythonhosted.org/packages/eb/21/c125015bbb9a626c323a0908e3c997a255de043713553277b2eacf4b03f3/ninja_api_key-1.0.2.tar.gz",
"platform": null,
"description": "# 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\na. the whole API\n```Python\n# api.py\n\nfrom ninja import NinjaAPI\nfrom ninja_apikey.security import APIKeyAuth\n\n# ...\n\napi = NinjaAPI(auth=APIKeyAuth())\n\n# ...\n\n@api.get(\"/secure_endpoint\")\ndef secure_endpoint(request):\n return f\"Hello, {request.user}!\"\n```\n\nb. an specific endpoint\n```Python\n# api.py\n\nfrom ninja import NinjaAPI\nfrom ninja_apikey.security import APIKeyAuth\n\n# ...\n\nauth = APIKeyAuth()\napi = NinjaAPI()\n\n# ...\n\n@api.get(\"/secure_endpoint\", auth=auth)\ndef secure_endpoint(request):\n return f\"Hello, {request.user}!\"\n```\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\n",
"bugtrack_url": null,
"license": null,
"summary": "Django Ninja API Key Authentication",
"version": "1.0.2",
"project_urls": {
"Source": "https://github.com/lucasrcezimbra/ninja-api-key"
},
"split_keywords": [
"django",
" rest",
" ninja",
" auth",
" apikey"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "48b364019097ddd81737c953017c2d5ca5b781e73f512a65a57de145afe6fcb6",
"md5": "b910bedb899ccafc36ffa26ccdcc0408",
"sha256": "817076874cdc5f10afb941ecd45bceef4981feb23ad0a1fcdd070bc4f391a27e"
},
"downloads": -1,
"filename": "ninja_api_key-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b910bedb899ccafc36ffa26ccdcc0408",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6.2",
"size": 9526,
"upload_time": "2024-10-25T10:04:13",
"upload_time_iso_8601": "2024-10-25T10:04:13.329816Z",
"url": "https://files.pythonhosted.org/packages/48/b3/64019097ddd81737c953017c2d5ca5b781e73f512a65a57de145afe6fcb6/ninja_api_key-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "eb21c125015bbb9a626c323a0908e3c997a255de043713553277b2eacf4b03f3",
"md5": "728ead477b6c79240eb05da3bf1da07e",
"sha256": "cc1a64f6b79cee5e84bf6bbd2d2a8a03e938044db77ca8855ab1d6f75682441d"
},
"downloads": -1,
"filename": "ninja_api_key-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "728ead477b6c79240eb05da3bf1da07e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6.2",
"size": 6651,
"upload_time": "2024-10-25T10:04:14",
"upload_time_iso_8601": "2024-10-25T10:04:14.333246Z",
"url": "https://files.pythonhosted.org/packages/eb/21/c125015bbb9a626c323a0908e3c997a255de043713553277b2eacf4b03f3/ninja_api_key-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-25 10:04:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lucasrcezimbra",
"github_project": "ninja-api-key",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ninja-api-key"
}