Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth2 Authentication #693

Closed
wants to merge 18 commits into from
Closed

Conversation

dulacp
Copy link
Contributor

@dulacp dulacp commented Mar 1, 2013

After the OAuth1 PR, here is the OAuth2Authencation class as discussed in #8

I've incorporated some doc on "how to get started" with django-oauth2-provider but maybe you don't want to incorporate those kind of third-party-documentation. I made that as a temporary way for people to get started, waiting for the official doc to be ready.

@@ -859,7 +859,7 @@ pre {
}

code {
padding: 2px 4px;
padding: 1px 4px;
Copy link
Member

Choose a reason for hiding this comment

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

Keep any CSS changes to a separate pull req.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allright, I'll move them right now.

@tomchristie
Copy link
Member

Great stuff! Really excellent. Comments inline. 👍 :)

@dulacp
Copy link
Contributor Author

dulacp commented Mar 1, 2013

Thanks :)
And thank you for the comments too!

@dulacp
Copy link
Contributor Author

dulacp commented Mar 1, 2013

@thedrow I just forgot to add the "pip install" command to the .travis.yaml file.
I'm doing it right now!

from rest_framework.tests.utils import RequestFactory
from rest_framework.views import APIView
import json
import base64
import datetime
import unittest
Copy link
Member

Choose a reason for hiding this comment

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

Use 'from django.utils import unittest' for compatibility across different py versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks @tomchristie for this tip!

for a cross python versions compatibility
@dulacp
Copy link
Contributor Author

dulacp commented Mar 1, 2013

Well, the pull request is still failing !
For Python 3 Travis Jobs it's due to the shortuuid dependency of django-oauth2-provider that doesn't seem to be compatible with python 3. I'll investigate that.

I've just found out about tox, so I will make more tests before submitting another commit, promise !

@tomchristie
Copy link
Member

django-oauth2-provider isn't yet py3k compatible, so may as well drop it from tox and Travis for the moment. Just leaves Django 1.3 errors which are a bit more mysterious.

On 1 Mar 2013, at 23:36, Pierre Dulac notifications@github.com wrote:

Well, the pull request is still failing !
For Python 3 Travis Jobs it's due to the shortuuid dependency of django-oauth2-provider that doesn't seem to be compatible with python 3. I'll investigate that.

I've just found out about tox, so I will make more tests before submitting another commit, promise !


Reply to this email directly or view it on GitHub.

@dulacp
Copy link
Contributor Author

dulacp commented Mar 2, 2013

I agree, the Django 1.3 errors are pretty mysterious, but I've already came across a similar issue while implementing the OAuth2Authentication class. And it was because I used an undefined method... and instead of raising an AttributeError exception concerning the undefined method called, it mysteriously raised an AttributeError concerning the successful_authenticator method not found, which was silly.

But I don't know the reasons that can explain why python is mixing up exceptions like that.

@dulacp
Copy link
Contributor Author

dulacp commented Mar 2, 2013

I've finally cracked it ! :)

The mysterious error is due to the fact that the oauth2_provider module imported in compat.py#L1R433 does not allow submodule access like if want to do form = oauth2_provider.forms.ClientAuthForm().

So, when I create the form in authentication.py#L3R192 in fact it fails and raise an exception.

The thing I don't know is why the AttributeError exception raised is referencing to the successful_authenticator method and not to the original exception which is

AttributeError: 'module' object has no attribute 'forms'

@@ -14,6 +14,7 @@ env:
install:
- pip install $DJANGO
- pip install defusedxml==0.3
- "if [[ ${TRAVIS_PYTHON_VERSION::1} != '3' ]]; then pip install -e git+git://github.com/dulaccc/django-oauth2-provider.git#egg=django-oauth2-provider; fi"
Copy link
Member

Choose a reason for hiding this comment

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

What's different in your fork?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi used my fork, temporary, because I didn't get any return from the repo owner concerning my pull requests and other pull requesters too.

And in my fork, I made a fix to add the submodules import statements into the provider.oauth2.__init__ file to fix the error we were getting with Django 1.3
Moreover, I made changes to the README in order to point to the new documentation I'm refactoring.

Copy link
Member

Choose a reason for hiding this comment

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

Okay. Can't really merge this until it's pointed at the PyPI version. If we can use the PyPI version and workaround any import issues inside the compat module that'd be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand. I will change that.
But as @thedrow suggested, do you want me to then rebase the commit into the corresponding one where I initially use my fork ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I perfectly understand, and fortunately no one has forked my public fork so no harm :) I'll forced my commit to take into account the rebase, you're right this is the correct way to fix "commit mistakes" if no one fork those commits.

Copy link
Member

Choose a reason for hiding this comment

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

I don't care about history so much, so don't worry about rebase unless you want too.

On 6 Mar 2013, at 17:37, Pierre Dulac notifications@github.com wrote:

In .travis.yml:

@@ -14,6 +14,7 @@ env:
install:

  • pip install $DJANGO
  • pip install defusedxml==0.3
      • "if [[ ${TRAVIS_PYTHON_VERSION::1} != '3' ]]; then pip install -e git+git://github.com/dulaccc/django-oauth2-provider.git#egg=django-oauth2-provider; fi"
        I understand. I will change that.
        But as @thedrow suggested, do you want me to then rebase the commit into the corresponding one where I initially use my fork ?


Reply to this email directly or view it on GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes pushed. I've done a rebase to clean a little and avoid "doing this, undoing this, redoing this" ^^ and to learn in the same time the better practices.
The only thing is that it didn't seem to trigger the Travis builds.

@tomchristie
Copy link
Member

Correct.

On 6 March 2013 17:09, Omer Katz notifications@github.com wrote:

So this will only allow authenticating with your own oauth service right?
There's no client functionality that will allow you to authenticate with
other oauth providers as far as I can see. Am I correct?


Reply to this email directly or view it on GitHubhttps://github.com//pull/693#issuecomment-14512833
.

here by pip.

Once this package is successfully installed this source code will be
deleted (unless you remove this file).
Copy link
Member

Choose a reason for hiding this comment

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

Drop this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops... this shouldn't be here

@dulacp
Copy link
Contributor Author

dulacp commented Mar 6, 2013

Actually, the OAuth authentication class is pretty short. So, if you want to use another oauth provider you can easily adapt yours and write your own Authentication class.

@dulacp
Copy link
Contributor Author

dulacp commented Mar 6, 2013

Allright, I will learn how to use git rebase then.

@dulacp
Copy link
Contributor Author

dulacp commented Mar 6, 2013

Travis build isn't showing up but it was triggered build#5296716

tomchristie added a commit that referenced this pull request Mar 8, 2013
For the awesome OAuth 2 support in #693.
@tomchristie
Copy link
Member

Merged into #709.

@tomchristie tomchristie closed this Mar 8, 2013
@michaelmior
Copy link
Contributor

Awesome! Thanks a lot folks :)

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