Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
b2cea84f
Commit
b2cea84f
authored
Mar 27, 2013
by
Fernando Rocha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete remove of client checks from oauth2
Signed-off-by: Fernando Rocha <fernandogrd@gmail.com>
parent
f1b8fee4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
20 deletions
+3
-20
docs/api-guide/authentication.md
+1
-1
rest_framework/authentication.py
+2
-10
rest_framework/tests/authentication.py
+0
-9
No files found.
docs/api-guide/authentication.md
View file @
b2cea84f
...
@@ -294,7 +294,7 @@ The only thing needed to make the `OAuth2Authentication` class work is to insert
...
@@ -294,7 +294,7 @@ The only thing needed to make the `OAuth2Authentication` class work is to insert
The command line to test the authentication looks like:
The command line to test the authentication looks like:
curl -H "Authorization: Bearer <your-access-token>" http://localhost:8000/api/
?client_id=YOUR_CLIENT_ID\&client_secret=YOUR_CLIENT_SECRET
curl -H "Authorization: Bearer <your-access-token>" http://localhost:8000/api/
---
---
...
...
rest_framework/authentication.py
View file @
b2cea84f
...
@@ -316,19 +316,11 @@ class OAuth2Authentication(BaseAuthentication):
...
@@ -316,19 +316,11 @@ class OAuth2Authentication(BaseAuthentication):
"""
"""
Authenticate the request, given the access token.
Authenticate the request, given the access token.
"""
"""
client
=
None
# Authenticate the client
if
'client_id'
in
request
.
REQUEST
:
oauth2_client_form
=
oauth2_provider_forms
.
ClientAuthForm
(
request
.
REQUEST
)
if
not
oauth2_client_form
.
is_valid
():
raise
exceptions
.
AuthenticationFailed
(
'Client could not be validated'
)
client
=
oauth2_client_form
.
cleaned_data
.
get
(
'client'
)
try
:
try
:
token
=
oauth2_provider
.
models
.
AccessToken
.
objects
.
select_related
(
'user'
)
token
=
oauth2_provider
.
models
.
AccessToken
.
objects
.
select_related
(
'user'
)
if
client
is
not
None
:
# TODO: Change to timezone aware datetime when oauth2_provider add
token
=
token
.
filter
(
client
=
client
)
# support to it.
token
=
token
.
get
(
token
=
access_token
,
expires__gt
=
datetime
.
now
())
token
=
token
.
get
(
token
=
access_token
,
expires__gt
=
datetime
.
now
())
except
oauth2_provider
.
models
.
AccessToken
.
DoesNotExist
:
except
oauth2_provider
.
models
.
AccessToken
.
DoesNotExist
:
raise
exceptions
.
AuthenticationFailed
(
'Invalid token'
)
raise
exceptions
.
AuthenticationFailed
(
'Invalid token'
)
...
...
rest_framework/tests/authentication.py
View file @
b2cea84f
...
@@ -500,15 +500,6 @@ class OAuth2Tests(TestCase):
...
@@ -500,15 +500,6 @@ class OAuth2Tests(TestCase):
self
.
assertEqual
(
response
.
status_code
,
401
)
self
.
assertEqual
(
response
.
status_code
,
401
)
@unittest.skipUnless
(
oauth2_provider
,
'django-oauth2-provider not installed'
)
@unittest.skipUnless
(
oauth2_provider
,
'django-oauth2-provider not installed'
)
def
test_get_form_with_wrong_client_data_failing_auth
(
self
):
"""Ensure GETing form over OAuth with incorrect client credentials fails"""
auth
=
self
.
_create_authorization_header
()
params
=
self
.
_client_credentials_params
()
params
[
'client_id'
]
+=
'a'
response
=
self
.
csrf_client
.
get
(
'/oauth2-test/'
,
params
,
HTTP_AUTHORIZATION
=
auth
)
self
.
assertEqual
(
response
.
status_code
,
401
)
@unittest.skipUnless
(
oauth2_provider
,
'django-oauth2-provider not installed'
)
def
test_get_form_passing_auth
(
self
):
def
test_get_form_passing_auth
(
self
):
"""Ensure GETing form over OAuth with correct client credentials succeed"""
"""Ensure GETing form over OAuth with correct client credentials succeed"""
auth
=
self
.
_create_authorization_header
()
auth
=
self
.
_create_authorization_header
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment