From e292f5a8691bcda5154510b5f1be367e98d5a371 Mon Sep 17 00:00:00 2001 From: Michele Comitini Date: Fri, 8 Mar 2013 18:36:06 +0100 Subject: [PATCH] removed http_x_forwarded for until a better solution is found. --- gluon/contrib/login_methods/oauth10a_account.py | 6 +----- gluon/contrib/login_methods/oauth20_account.py | 9 ++++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/gluon/contrib/login_methods/oauth10a_account.py b/gluon/contrib/login_methods/oauth10a_account.py index d3341570..98b61a0f 100644 --- a/gluon/contrib/login_methods/oauth10a_account.py +++ b/gluon/contrib/login_methods/oauth10a_account.py @@ -15,8 +15,6 @@ Dependencies: import oauth2 as oauth import cgi -from urllib2 import urlopen -import urllib2 from urllib import urlencode from gluon import current @@ -64,9 +62,7 @@ class OAuthAccount(object): Appends the _next action to the generated url so the flows continues. """ r = self.request - http_host = r.env.http_x_forwarded_for - if not http_host: - http_host = r.env.http_host + http_host = r.env.http_host url_scheme = r.env.wsgi_url_scheme if next: diff --git a/gluon/contrib/login_methods/oauth20_account.py b/gluon/contrib/login_methods/oauth20_account.py index 195590a8..1bf0a551 100644 --- a/gluon/contrib/login_methods/oauth20_account.py +++ b/gluon/contrib/login_methods/oauth20_account.py @@ -103,9 +103,7 @@ server for requests. It can be used for the optional"scope" parameters for Face """ r = current.request - http_host = r.env.http_x_forwarded_for - if not http_host: - http_host = r.env.http_host + http_host = r.env.http_host if r.env.https == 'on': url_scheme = 'https' @@ -163,7 +161,7 @@ server for requests. It can be used for the optional"scope" parameters for Face open_url = None opener = self.__build_url_opener(self.token_url) try: - open_url = opener.open(self.token_url, urlencode(data)) + open_url = opener.open(self.token_url, urlencode(data), self.socket_timeout) except urllib2.HTTPError, e: tmp = e.read() raise Exception(tmp) @@ -208,7 +206,7 @@ server for requests. It can be used for the optional"scope" parameters for Face def __init__(self, g=None, client_id=None, client_secret=None, - auth_url=None, token_url=None, **args): + auth_url=None, token_url=None, socket_timeout=60, **args): """ first argument is unused. Here only for legacy reasons. """ @@ -224,6 +222,7 @@ server for requests. It can be used for the optional"scope" parameters for Face self.auth_url = auth_url self.token_url = token_url self.args = args + self.socket_timeout = socket_timeout def login_url(self, next="/"): self.__oauth_login(next)