Skip to content

Commit 3c652f7

Browse files
committed
Misc. style fixes
1 parent 9f72a35 commit 3c652f7

File tree

8 files changed

+38
-36
lines changed

8 files changed

+38
-36
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ matrix:
2121
- env: TOXENV=py36-djangomaster
2222

2323
install:
24-
- pip install tox "virtualenv<14"
25-
- pip install coveralls
24+
- pip install coveralls tox "virtualenv<14"
2625

2726
script:
2827
- tox

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ Changelog
9898
---------
9999

100100
0.12.0 [Unreleased]
101-
~~~~~~~~~~
101+
~~~~~~~~~~~~~~~~~~~
102102

103103
* **Dropped support for Python 3.2 and Python 3.3**, added support for Python 3.6
104104
* Support for the `scopes` query parameter, deprecated in 0.6.1, has been dropped
105105
* #448: Added support for customizing applications' allowed grant types
106106

107107
0.11.0 [2016-12-1]
108-
~~~~~~~~~~~
108+
~~~~~~~~~~~~~~~~~~
109109

110110
* #315: AuthorizationView does not overwrite requests on get
111111
* #425: Added support for Django 1.10

oauth2_provider/decorators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
def protected_resource(scopes=None, validator_cls=OAuth2Validator, server_cls=Server):
1313
"""
14-
Decorator to protect views by providing OAuth2 authentication out of the box, optionally with
15-
scope handling.
14+
Decorator to protect views by providing OAuth2 authentication out of the box,
15+
optionally with scope handling.
1616
1717
@protected_resource()
1818
def my_view(request):
@@ -38,8 +38,8 @@ def _validate(request, *args, **kwargs):
3838

3939
def rw_protected_resource(scopes=None, validator_cls=OAuth2Validator, server_cls=Server):
4040
"""
41-
Decorator to protect views by providing OAuth2 authentication and read/write scopes out of the
42-
box.
41+
Decorator to protect views by providing OAuth2 authentication and read/write scopes
42+
out of the box.
4343
GET, HEAD, OPTIONS http methods require "read" scope. Otherwise "write" scope is required.
4444
4545
@rw_protected_resource()

oauth2_provider/ext/rest_framework/permissions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class IsAuthenticatedOrTokenHasScope(BasePermission):
9393
This only returns True if the user is authenticated, but not using a token
9494
or using a token, and the token has the correct scope.
9595
96-
This is usefull when combined with the DjangoModelPermissions to allow people browse the browsable api's
97-
if they log in using the a non token bassed middleware,
96+
This is usefull when combined with the DjangoModelPermissions to allow people browse
97+
the browsable api's if they log in using the a non token bassed middleware,
9898
and let them access the api's using a rest client with a token
9999
"""
100100
def has_permission(self, request, view):

oauth2_provider/generators.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ def hash(self):
1818
class ClientIdGenerator(BaseHashGenerator):
1919
def hash(self):
2020
"""
21-
Generate a client_id without colon char as in http://tools.ietf.org/html/rfc2617#section-2
22-
for Basic Authentication scheme
21+
Generate a client_id for Basic Authentication scheme without colon char
22+
as in http://tools.ietf.org/html/rfc2617#section-2
2323
"""
2424
return oauthlib_generate_client_id(length=40, chars=UNICODE_ASCII_CHARACTER_SET)
2525

2626

2727
class ClientSecretGenerator(BaseHashGenerator):
2828
def hash(self):
29-
return oauthlib_generate_client_id(length=oauth2_settings.CLIENT_SECRET_GENERATOR_LENGTH,
30-
chars=UNICODE_ASCII_CHARACTER_SET)
29+
length = oauth2_settings.CLIENT_SECRET_GENERATOR_LENGTH
30+
chars = UNICODE_ASCII_CHARACTER_SET
31+
return oauthlib_generate_client_id(length=length, chars=chars)
3132

3233

3334
def generate_client_id():

oauth2_provider/oauth2_backends.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def __init__(self, server=None):
2222

2323
def _get_escaped_full_path(self, request):
2424
"""
25-
Django considers "safe" some characters that aren't so for oauthlib. We have to search for
26-
them and properly escape.
25+
Django considers "safe" some characters that aren't so for oauthlib.
26+
We have to search for them and properly escape.
2727
"""
2828
parsed = list(urlparse(request.get_full_path()))
2929
unsafe = set(c for c in parsed[4]).difference(urlencoded)
@@ -45,8 +45,9 @@ def _get_extra_credentials(self, request):
4545

4646
def _extract_params(self, request):
4747
"""
48-
Extract parameters from the Django request object. Such parameters will then be passed to
49-
OAuthLib to build its own Request object. The body should be encoded using OAuthLib urlencoded
48+
Extract parameters from the Django request object.
49+
Such parameters will then be passed to OAuthLib to build its own
50+
Request object. The body should be encoded using OAuthLib urlencoded.
5051
"""
5152
uri = self._get_escaped_full_path(request)
5253
http_method = request.method
@@ -170,7 +171,7 @@ def verify_request(self, request, scopes):
170171

171172
class JSONOAuthLibCore(OAuthLibCore):
172173
"""
173-
Extends the default OAuthLibCore to parse correctly requests with application/json Content-Type
174+
Extends the default OAuthLibCore to parse correctly application/json requests
174175
"""
175176
def extract_body(self, request):
176177
"""

oauth2_provider/oauth2_validators.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .models import Grant, AccessToken, RefreshToken, get_application_model, AbstractApplication
1818
from .settings import oauth2_settings
1919

20+
2021
log = logging.getLogger('oauth2_provider')
2122

2223
GRANT_TYPE_MAPPING = {
@@ -31,7 +32,8 @@
3132
class OAuth2Validator(RequestValidator):
3233
def _extract_basic_auth(self, request):
3334
"""
34-
Return authentication string if request contains basic auth credentials, else return None
35+
Return authentication string if request contains basic auth credentials,
36+
otherwise return None
3537
"""
3638
auth = request.headers.get('HTTP_AUTHORIZATION', None)
3739
if not auth:
@@ -93,11 +95,12 @@ def _authenticate_basic_auth(self, request):
9395

9496
def _authenticate_request_body(self, request):
9597
"""
96-
Try to authenticate the client using client_id and client_secret parameters
97-
included in body.
98+
Try to authenticate the client using client_id and client_secret
99+
parameters included in body.
98100
99-
Remember that this method is NOT RECOMMENDED and SHOULD be limited to clients unable to
100-
directly utilize the HTTP Basic authentication scheme. See rfc:`2.3.1` for more details.
101+
Remember that this method is NOT RECOMMENDED and SHOULD be limited to
102+
clients unable to directly utilize the HTTP Basic authentication scheme.
103+
See rfc:`2.3.1` for more details.
101104
"""
102105
# TODO: check if oauthlib has already unquoted client_id and client_secret
103106
try:
@@ -117,8 +120,8 @@ def _authenticate_request_body(self, request):
117120

118121
def _load_application(self, client_id, request):
119122
"""
120-
If request.client was not set, load application instance for given client_id and store it
121-
in request.client
123+
If request.client was not set, load application instance for given
124+
client_id and store it in request.client
122125
"""
123126

124127
# we want to be sure that request has the client attribute!
@@ -141,11 +144,11 @@ def client_authentication_required(self, request, *args, **kwargs):
141144
* Resource owner password grant
142145
* Refresh token grant
143146
144-
If the request contains authorization headers, always authenticate the client no matter
145-
the grant type.
147+
If the request contains authorization headers, always authenticate the client
148+
no matter the grant type.
146149
147-
If the request does not contain authorization headers, proceed with authentication only if
148-
the client is of type `Confidential`.
150+
If the request does not contain authorization headers, proceed with authentication
151+
only if the client is of type `Confidential`.
149152
150153
If something goes wrong, call oauthlib implementation of the method.
151154
"""
@@ -172,9 +175,10 @@ def authenticate_client(self, request, *args, **kwargs):
172175
173176
First we try to authenticate with HTTP Basic Auth, and that is the PREFERRED
174177
authentication method.
175-
Whether this fails we support including the client credentials in the request-body, but
176-
this method is NOT RECOMMENDED and SHOULD be limited to clients unable to directly utilize
177-
the HTTP Basic authentication scheme. See rfc:`2.3.1` for more details
178+
Whether this fails we support including the client credentials in the request-body,
179+
but this method is NOT RECOMMENDED and SHOULD be limited to clients unable to
180+
directly utilize the HTTP Basic authentication scheme.
181+
See rfc:`2.3.1` for more details
178182
"""
179183
authenticated = self._authenticate_basic_auth(request)
180184

oauth2_provider/templates/oauth2_provider/base.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,3 @@
4646

4747
</body>
4848
</html>
49-
50-
51-

0 commit comments

Comments
 (0)