Squid frontend + Tornado backend -> Google OpenID ERROR

37 views
Skip to first unread message

Gang(Gary) Wu

unread,
Nov 23, 2009, 4:41:49 AM11/23/09
to python-...@googlegroups.com
I have setup a web site build by tornado web framework, but my frontend is squid.

I have hacked code for openid logging problem.


--- a/tornado/auth.py
+++ b/tornado/auth.py
@@ -96,7 +96,8 @@ class OpenIdMixin(object):
             self._on_authentication_verified, callback))
 
     def _openid_args(self, callback_uri, ax_attrs=[], oauth_scope=None):
-        url = urlparse.urljoin(self.request.full_url(), callback_uri)
+        url = urlparse.urljoin("http://"+self.request.host, callback_uri)
+        logging.info("URL : %s",url)
         args = {
             "openid.ns": "http://specs.openid.net/auth/2.0",
             "openid.claimed_id":
diff --git a/tornado/httpserver.py b/tornado/httpserver.py
index 460f5c8..63e502f 100644
--- a/tornado/httpserver.py
+++ b/tornado/httpserver.py
@@ -278,6 +278,7 @@ class HTTPRequest(object):
         self.body = body or ""
         if connection and connection.xheaders:
             self.remote_ip = headers.get("X-Real-Ip", remote_ip)
+           self.remote_ip = headers.get("X-Forwarded-For",remote_ip).split(' ')[0]
             self.protocol = headers.get("X-Scheme", protocol) or "http"
         else:
             self.remote_ip = remote_ip


Because in squid proxy use X-Forwarded-For instead of X-Real-Ip

and self.request.full_url() will return error url because of squid proxy


Yours sincerely Wu Gang

Bret Taylor

unread,
Nov 24, 2009, 1:25:18 PM11/24/09
to python-...@googlegroups.com
Thanks, we will incorporate a variation of this patch.

Bret Taylor

unread,
Nov 24, 2009, 1:27:44 PM11/24/09
to python-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages