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

Return 503 instead of raise 500 error when auth provider not accessible #304

Closed
zee-why opened this issue Jun 19, 2014 · 3 comments
Closed

Comments

@zee-why
Copy link

zee-why commented Jun 19, 2014

I'm using python-social-auth with Django. Url configs as:
url('', include('social.apps.django_app.urls', namespace='social'))
Currently, when auth providers are not accessible or there is any error returned from provider, python-social-auth always raise an error which makes 500 response. From my point of view, when auth provider not accessible, it's more reasonable to return a 503 instead of raising 500. 500 is not good to SEO. What's your opinion on it?

@omab
Copy link
Owner

omab commented Jun 20, 2014

You can easily implement that behavior by subclassing the built-in middleware here https://github.com/omab/python-social-auth/blob/master/social/apps/django_app/middleware.py

@zee-why
Copy link
Author

zee-why commented Jun 20, 2014

Thanks for point out the built-in middleware.

I tried it, then found a small issue here: https://github.com/omab/python-social-auth/blob/master/social/backends/oauth.py
Unlike BaseOAuth2.auth_complete, the BaseOAuth2.do_auth doesn't handle HTTPError (similar issue may also exist somewhere else). As a result, errors from do_auth won't be handled by SocialAuthExceptionMiddleware. If I write a custom middleware, I can check URL to determine where the HTTPError come from. It's an OK solution, but seems not very elegant to me. Are there any considerations of why do_auth not handling HTTPError like auth_complete?

@omab
Copy link
Owner

omab commented Jun 20, 2014

There's no reason for do_auth not handle HTTPError, the code is just missing and I'll add it soon.

@omab omab closed this as completed in 7dd4273 Apr 4, 2015
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

No branches or pull requests

2 participants