|
1 | | -# django-rest-framework-api-key |
| 1 | +# django-rest-framework-api-key [![travis][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url] [![pypi][pypi-image]][pypi-url] |
2 | 2 | Authenticate Web APIs made with Django REST Framework |
| 3 | + |
| 4 | + |
| 5 | +### Supports |
| 6 | + |
| 7 | + - Python (2.7, 3.3, 3.4, 3.5) |
| 8 | + - Django (1.8, 1.9, 1.10) |
| 9 | + - Django Rest Framework (3+) |
| 10 | + |
| 11 | + |
| 12 | +### Installation |
| 13 | + |
| 14 | +Install using pip: |
| 15 | + |
| 16 | + pip install drfapikey |
| 17 | + |
| 18 | +Add 'rest_framework_api_key' to your `INSTALLED_APPS` setting: |
| 19 | + |
| 20 | + INSTALLED_APPS = ( |
| 21 | + ... |
| 22 | + 'rest_framework_api_key', |
| 23 | + ) |
| 24 | + |
| 25 | +Finally set the django-rest-framework permissions under your django settings: |
| 26 | + |
| 27 | + REST_FRAMEWORK = { |
| 28 | + 'DEFAULT_PERMISSION_CLASSES': ( |
| 29 | + 'rest_framework_api_key.permissions.HasAPIAccess', |
| 30 | + ) |
| 31 | + } |
| 32 | + |
| 33 | + |
| 34 | +### Example Request |
| 35 | + |
| 36 | +```python |
| 37 | +response = requests.get( |
| 38 | + url="http://0.0.0.0:8000/api/login", |
| 39 | + headers={ |
| 40 | + "Api-Key": "fd8b4a98c8f53035aeab410258430e2d86079c93", |
| 41 | + }, |
| 42 | +) |
| 43 | +``` |
| 44 | + |
| 45 | + |
| 46 | +### Tests |
| 47 | + |
| 48 | + pyvenv env |
| 49 | + source env/bin/activate |
| 50 | + pip install -r requirements/requirements-testing.txt |
| 51 | + python runtests.py |
| 52 | + |
| 53 | + |
| 54 | +### Contributing |
| 55 | + |
| 56 | +1. Fork it! |
| 57 | +2. Create your feature branch: `git checkout -b my-new-feature` |
| 58 | +3. Commit your changes: `git commit -am 'Add some feature'` |
| 59 | +4. Push to the branch: `git push origin my-new-feature` |
| 60 | +5. Submit a pull request |
| 61 | +6. Make sure tests are passing |
| 62 | + |
| 63 | + |
| 64 | +[travis-image]: https://travis-ci.org/ekonstantinidis/django-rest-framework-api-key.svg?branch=master |
| 65 | +[travis-url]: https://travis-ci.org/ekonstantinidis/django-rest-framework-api-key |
| 66 | + |
| 67 | +[codecov-image]: https://codecov.io/github/ekonstantinidis/django-rest-framework-api-key/coverage.svg?branch=master |
| 68 | +[codecov-url]:https://codecov.io/github/ekonstantinidis/django-rest-framework-api-key?branch=master |
| 69 | + |
| 70 | +[pypi-image]: https://badge.fury.io/py/drfapikey.svg |
| 71 | +[pypi-url]: https://pypi.python.org/pypi/drfapikey/ |
0 commit comments