diff --git a/.travis.yml b/.travis.yml index 172fe7f..0393058 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,15 +5,17 @@ sudo: false env: - TOX_ENV=py27-flake8 - TOX_ENV=py27-docs - - TOX_ENV=py26-django1.6-drf2.4.3 - - TOX_ENV=py26-django1.6-drf2.4.4 - - TOX_ENV=py26-django1.6-drf3.0 - - TOX_ENV=py27-django1.6-drf2.4.3 - - TOX_ENV=py27-django1.6-drf2.4.4 - - TOX_ENV=py27-django1.6-drf3.0 - - TOX_ENV=py27-django1.7-drf2.4.3 - - TOX_ENV=py27-django1.7-drf2.4.4 - - TOX_ENV=py27-django1.7-drf3.0 + - TOX_ENV=py26-django16-drf24 + - TOX_ENV=py26-django16-drf30 + - TOX_ENV=py26-django16-drf31 + - TOX_ENV=py27-django16-drf24 + - TOX_ENV=py27-django16-drf24 + - TOX_ENV=py27-django16-drf30 + - TOX_ENV=py27-django16-drf31 + - TOX_ENV=py27-django17-drf24 + - TOX_ENV=py27-django17-drf24 + - TOX_ENV=py27-django17-drf30 + - TOX_ENV=py27-django17-drf31 matrix: fast_finish: true diff --git a/LICENSE b/LICENSE index 9014be9..36de81b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,27 @@ Copyright (c) 2014, José Padilla +All rights reserved. -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in index 09b39b0..ca446cc 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,2 @@ recursive-exclude * __pycache__ recursive-exclude * *.py[co] -include requirements.txt diff --git a/README.md b/README.md index 66e1164..036c498 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,9 @@ Full documentation for the project is available at [http://jpadilla.github.io/dj You may also want to follow the [author][jpadilla] on Twitter. -[build-status-image]: https://secure.travis-ci.org/jpadilla/django-rest-framework-oauth.png?branch=master +[build-status-image]: https://secure.travis-ci.org/jpadilla/django-rest-framework-oauth.svg?branch=master [travis]: http://travis-ci.org/jpadilla/django-rest-framework-oauth?branch=master -[pypi-version]: https://pypip.in/version/djangorestframework-oauth/badge.svg +[pypi-version]: https://img.shields.io/pypi/v/djangorestframework-oauth.svg [pypi]: https://pypi.python.org/pypi/djangorestframework-oauth [django-oauth-plus]: http://code.larlet.fr/django-oauth-plus/wiki/Home [django-oauth2-provider]: http://django-oauth2-provider.readthedocs.org/ diff --git a/docs/index.md b/docs/index.md index dbb2996..7c6a00b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,7 +3,7 @@ - + @@ -17,9 +17,9 @@ OAuth support for Django REST Framework ## Overview -OAuth support extracted as a third party package directly from the official Django REST Framework implementation. It's built using the [django-oauth-plus][django-oauth-plus] and [django-oauth2-provider][django-oauth2-provider] packages. +OAuth support extracted as a third party package directly from the official Django REST Framework implementation. It's built to use the [django-oauth-plus][django-oauth-plus], [oauth2][oauth2], and [django-oauth2-provider][django-oauth2-provider] packages. -This package provides two authentication classes: [OAuthAuthentication][oauth-authentication] and [OAuth2Authentication][oauth2-authentication] and a [TokenHasReadWriteScope][token-has-read-write-scope] permission class. +This package provides two authentication classes, [OAuthAuthentication][oauth-authentication] and [OAuth2Authentication][oauth2-authentication], and a [TokenHasReadWriteScope][token-has-read-write-scope] permission class. ## Requirements @@ -29,12 +29,26 @@ This package provides two authentication classes: [OAuthAuthentication][oauth-au ## Installation -Install using `pip`... +Install using `pip`: ```bash $ pip install djangorestframework-oauth ``` +OAuth packages are optional and not installed out of the box. Use of `OAuthAuthentication` requires installation of the `django-oauth-plus` and `oauth2` packages: + +```bash +$ pip install django-oauth-plus oauth2 +``` + +Use of `OAuth2Authentication` requires installation of `django-oauth2-provider`: + +```bash +$ pip install django-oauth2-provider +``` + +Use of `TokenHasReadWriteScope` requires installation of either `django-oauth-plus` or `django-oauth2-provider`. + ## Documentation & Support Full documentation for the project is available at http://jpadilla.github.io/django-rest-framework-oauth/. @@ -47,7 +61,6 @@ Install testing requirements. ```bash $ pip install -r requirements.txt -$ pip install -r requirements-test.txt ``` Run with runtests. @@ -87,5 +100,6 @@ $ mkdocs build [oauth2-authentication]: authentication.md#oauth2authentication [token-has-read-write-scope]: permissions.md#tokenhasreadwritescope [django-oauth-plus]: http://code.larlet.fr/django-oauth-plus/wiki/Home +[oauth2]: https://github.com/joestump/python-oauth2 [django-oauth2-provider]: http://django-oauth2-provider.readthedocs.org/ [jpadilla]: https://twitter.com/jpadilla_ diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index a0f5aea..0000000 --- a/requirements-test.txt +++ /dev/null @@ -1,6 +0,0 @@ -Django>=1.6 -djangorestframework>=2.4.3 -pytest-django==2.6 -pytest==2.5.2 -pytest-cov==1.6 -flake8==2.2.2 diff --git a/requirements.txt b/requirements.txt index 05a803d..eb61826 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,9 @@ +Django>=1.6,<1.8 +djangorestframework>=2.4.3 django-oauth-plus>=2.2.1 -oauth2>=1.5.211 django-oauth2-provider>=0.2.4 +flake8==2.2.2 +oauth2==1.5.211 +pytest-cov==1.6 +pytest-django==2.6 +pytest==2.5.2 diff --git a/rest_framework_oauth/__init__.py b/rest_framework_oauth/__init__.py index 1f356cc..1a72d32 100644 --- a/rest_framework_oauth/__init__.py +++ b/rest_framework_oauth/__init__.py @@ -1 +1 @@ -__version__ = '1.0.0' +__version__ = '1.1.0' diff --git a/rest_framework_oauth/authentication.py b/rest_framework_oauth/authentication.py index 7cd60da..c504ffd 100644 --- a/rest_framework_oauth/authentication.py +++ b/rest_framework_oauth/authentication.py @@ -8,8 +8,9 @@ from rest_framework import exceptions from rest_framework.authentication import get_authorization_header, BaseAuthentication -from rest_framework.compat import oauth, oauth_provider, oauth_provider_store -from rest_framework.compat import oauth2_provider, provider_now, check_nonce + +from .compat import oauth, oauth_provider, oauth_provider_store +from .compat import oauth2_provider, provider_now, check_nonce class OAuthAuthentication(BaseAuthentication): diff --git a/rest_framework_oauth/permissions.py b/rest_framework_oauth/permissions.py index dadbac5..f290c3c 100644 --- a/rest_framework_oauth/permissions.py +++ b/rest_framework_oauth/permissions.py @@ -4,7 +4,8 @@ from __future__ import unicode_literals from rest_framework.permissions import SAFE_METHODS, BasePermission -from rest_framework.compat import oauth2_provider_scope, oauth2_constants + +from .compat import oauth2_provider_scope, oauth2_constants class TokenHasReadWriteScope(BasePermission): diff --git a/setup.py b/setup.py index 359d1ad..6eb1e2f 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,6 @@ author = 'José Padilla' author_email = 'hello@jpadilla.com' license = 'BSD' -install_requires = open('requirements.txt').read().split('\n') # This command has been borrowed from @@ -88,13 +87,12 @@ def get_package_data(package): packages=get_packages(package), package_data=get_package_data(package), cmdclass={'test': PyTest}, - install_requires=install_requires, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Framework :: Django', 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', + 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Natural Language :: English', 'Programming Language :: Python :: 2', diff --git a/tests/test_authentication.py b/tests/test_authentication.py index 4b77685..f0f8843 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -9,7 +9,9 @@ from django.utils import unittest from django.utils.http import urlencode -from rest_framework import status, permissions +from rest_framework import status +from rest_framework.permissions import IsAuthenticated +from rest_framework_oauth import permissions from rest_framework_oauth.authentication import OAuthAuthentication, OAuth2Authentication from rest_framework_oauth.compat import oauth2_provider, oauth2_provider_scope from rest_framework_oauth.compat import oauth, oauth_provider @@ -21,7 +23,7 @@ class MockView(APIView): - permission_classes = (permissions.IsAuthenticated,) + permission_classes = (IsAuthenticated,) def get(self, request): return HttpResponse({'a': 1, 'b': 2, 'c': 3}) diff --git a/tox.ini b/tox.ini index cdfc70a..ec9485c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,20 +1,23 @@ [tox] envlist = py27-{flake8,docs}, - {py26}-django{16}-drf{2.4.3,2.4.4,3.0}, - {py27}-django{1.6,1.7}-drf{2.4.3,2.4.4,3.0} + {py26}-django{16}-drf{24,30,31}, + {py27}-django{16,17}-drf{24,30,31} [testenv] commands = ./runtests.py --fast setenv = PYTHONDONTWRITEBYTECODE=1 deps = - django1.6: Django==1.6.8 - django1.7: Django==1.7.1 - drf2.4.3: djangorestframework==2.4.3 - drf2.4.4: djangorestframework==2.4.4 - drf3.0: https://github.com/tomchristie/django-rest-framework/archive/3.0-beta.zip + django16: Django==1.6.3 + django17: Django==1.7.2 + drf24: djangorestframework==2.4.3 + drf30: djangorestframework==3.0.0 + drf31: djangorestframework==3.1.0 pytest-django==2.6.1 + django-oauth-plus>=2.2.1 + oauth2==1.5.211 + django-oauth2-provider>=0.2.4 [testenv:py27-flake8] commands = ./runtests.py --lintonly