Clean up and PEP8 for #41.
This commit is contained in:
parent
69a7c3e2e3
commit
f92c725113
|
@ -1,8 +1,6 @@
|
||||||
from django.contrib.auth import authenticate
|
|
||||||
|
|
||||||
from ..utils import now
|
from ..utils import now
|
||||||
from .forms import ClientAuthForm, PublicPasswordGrantForm
|
from .forms import ClientAuthForm, PublicPasswordGrantForm
|
||||||
from .models import AccessToken, Client
|
from .models import AccessToken
|
||||||
|
|
||||||
|
|
||||||
class BaseBackend(object):
|
class BaseBackend(object):
|
||||||
|
@ -63,25 +61,9 @@ class RequestParamsClientBackend(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class RequestParamsClientBackend(object):
|
|
||||||
"""
|
|
||||||
Backend that tries to authenticate a client through request parameters
|
|
||||||
which might be in the request body or URI as defined in :rfc:`2.3.1`.
|
|
||||||
"""
|
|
||||||
def authenticate(self, request=None):
|
|
||||||
if request is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
form = ClientAuthForm(request.REQUEST)
|
|
||||||
|
|
||||||
if form.is_valid():
|
|
||||||
return form.cleaned_data.get('client')
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
class PublicPasswordBackend(object):
|
class PublicPasswordBackend(object):
|
||||||
"""
|
"""
|
||||||
Backend that tries to authenticate a client using username, password
|
Backend that tries to authenticate a client using username, password
|
||||||
and client ID. This is only available in specific circumstances:
|
and client ID. This is only available in specific circumstances:
|
||||||
|
|
||||||
- grant_type is "password"
|
- grant_type is "password"
|
||||||
|
@ -100,7 +82,6 @@ class PublicPasswordBackend(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AccessTokenBackend(object):
|
class AccessTokenBackend(object):
|
||||||
"""
|
"""
|
||||||
Authenticate a user via access token and client object.
|
Authenticate a user via access token and client object.
|
||||||
|
|
|
@ -302,6 +302,7 @@ class PasswordGrantForm(ScopeMixin, OAuthForm):
|
||||||
data['user'] = user
|
data['user'] = user
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
class PublicPasswordGrantForm(PasswordGrantForm):
|
class PublicPasswordGrantForm(PasswordGrantForm):
|
||||||
client_id = forms.CharField(required=True)
|
client_id = forms.CharField(required=True)
|
||||||
grant_type = forms.CharField(required=True)
|
grant_type = forms.CharField(required=True)
|
||||||
|
@ -327,8 +328,3 @@ class PublicPasswordGrantForm(PasswordGrantForm):
|
||||||
|
|
||||||
data['client'] = client
|
data['client'] = client
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue