It's default value is ``DEBUG``, so you need to set it to ``False`` to avoid
tracebacks when ``DEBUG = True``.
+- When your project is behind a reverse proxy that uses HTTPS the redirect URIs
+ can became with the wrong schema (``http://`` instead of ``https://``), and
+ might cause errors with the auth process, to force HTTPS in the final URIs
+ define this setting::
+
+ SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
+
Some settings can be tweak by backend by adding the backend name prefix (all
uppercase and replace ``-`` with ``_``), here's the supported settings so far::
It's default value is ``DEBUG``, so you need to set it to ``False`` to avoid
tracebacks when ``DEBUG = True``.
+- When your project is behind a reverse proxy that uses HTTPS the redirect URIs
+ can became with the wrong schema (``http://`` instead of ``https://``), and
+ might cause errors with the auth process, to force HTTPS in the final URIs
+ define this setting::
+
+ SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
Some settings can be tweak by backend by adding the backend name prefix (all
uppercase and replace ``-`` with ``_``), here's the supported settings so far::
else:
user.social_auth.filter(provider=self.AUTH_BACKEND.name).delete()
+ def build_absolute_uri(self, path=None):
+ """Build absolute URI for given path. Replace http:// schema with
+ https:// if SOCIAL_AUTH_REDIRECT_IS_HTTPS is defined.
+ """
+ uri = self.request.build_absolute_uri(path)
+ if setting('SOCIAL_AUTH_REDIRECT_IS_HTTPS'):
+ uri = uri.replace('http://', 'https://')
+ return uri
+
class OpenIdAuth(BaseAuth):
"""OpenId process handling"""
"""Return auth URL returned by service"""
openid_request = self.setup_request(self.auth_extra_arguments())
# Construct completion URL, including page we should redirect to
- return_to = self.request.build_absolute_uri(self.redirect)
+ return_to = self.build_absolute_uri(self.redirect)
return openid_request.redirectURL(self.trust_root(), return_to)
def auth_html(self):
"""Return auth HTML returned by service"""
openid_request = self.setup_request(self.auth_extra_arguments())
- return_to = self.request.build_absolute_uri(self.redirect)
+ return_to = self.build_absolute_uri(self.redirect)
form_tag = {'id': 'openid_message'}
return openid_request.htmlMarkup(self.trust_root(), return_to,
form_tag_attrs=form_tag)
def trust_root(self):
"""Return trust-root option"""
- return setting('OPENID_TRUST_ROOT') or \
- self.request.build_absolute_uri('/')
+ return setting('OPENID_TRUST_ROOT') or self.build_absolute_uri('/')
def continue_pipeline(self, *args, **kwargs):
"""Continue previous halted pipeline"""
response = self.consumer().complete(dict(self.data.items()),
- self.request.build_absolute_uri())
+ self.build_absolute_uri())
kwargs.update({
'auth': self,
'response': response,
def auth_complete(self, *args, **kwargs):
"""Complete auth process"""
response = self.consumer().complete(dict(self.data.items()),
- self.request.build_absolute_uri())
+ self.build_absolute_uri())
if not response:
raise AuthException(self, 'OpenID relying party endpoint')
elif response.status == SUCCESS:
def __init__(self, request, redirect):
"""Init method"""
super(BaseOAuth, self).__init__(request, redirect)
- self.redirect_uri = self.request.build_absolute_uri(self.redirect)
+ self.redirect_uri = self.build_absolute_uri(self.redirect)
class ConsumerBasedOAuth(BaseOAuth):