Skip to content

Add support for OAuth2 authentication - #25

Merged
rlucioni merged 1 commit into
masterfrom
renzo/oauth
Feb 22, 2016
Merged

Add support for OAuth2 authentication#25
rlucioni merged 1 commit into
masterfrom
renzo/oauth

Conversation

@rlucioni

Copy link
Copy Markdown

A management command in the programs app will make calls to the API provided by this package with an OAuth 2.0 access token. Requires changes from edx/django-rest-framework-oauth#2.

@jimabramson please review.

Comment thread setup.py Outdated
'djangorestframework>=3.2.0,<3.4.0',
'djangorestframework-jwt>=1.6.0,<=1.7.2',
'edx-opaque-keys>=0.1.2,<1.0.0',
'edx-djangorestframework-oauth==1.0.1',

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clintonb worth mentioning: if we get rid of the edx-djangorestframework-oauth fork as proposed in https://github.com/edx/edx-platform/pull/11559, we'll need to carefully order imports here, too, so that django-oauth2-provider is shadowed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=1.0.1,<2.0.0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clintonb updated.

@jimabramson

Copy link
Copy Markdown

@rlucioni why no tests?

@rlucioni

Copy link
Copy Markdown
Author

@jimabramson miss on my part. Tests added.

Comment thread organizations/v0/tests/test_views.py Outdated
self.organization_list_url,
HTTP_AUTHORIZATION='Bearer {}'.format('nonexistent-access-token')
)
self.assertEqual(response.status_code, 403)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if OAuth2Authentication is moved to the top of the authentication_classes list, I think this response code will become a 401, which is a more desirable (i.e. correct) result.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought re-ordering the authentication classes would yield the more correct 401, but it doesn't appear to. I'll poke around a little longer.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out re-ordering the classes does work as expected. I was being thrown off by some test cases. The view now returns a 401 when authentication fails.

@jimabramson

Copy link
Copy Markdown

@rlucioni apart from my proposal to try and get a 401 instead of a 403, LGTM 👍

rlucioni pushed a commit that referenced this pull request Feb 22, 2016
Add support for OAuth2 authentication
@rlucioni
rlucioni merged commit 8c500c6 into master Feb 22, 2016
@rlucioni
rlucioni deleted the renzo/oauth branch February 22, 2016 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants