0
@@ -69,6 +69,7 @@ def GetUserInfo(http_cookie, cookie_name=COOKIE_NAME):
0
cookie = Cookie.SimpleCookie(http_cookie)
0
if cookie_name in cookie:
0
cookie_value = cookie[cookie_name].value
0
@@ -81,10 +82,11 @@ def GetUserInfo(http_cookie, cookie_name=COOKIE_NAME):
0
vhsh = sha.new(email+nickname+admin+COOKIE_SECRET).hexdigest()
0
logging.info(email+" had invalid cookie")
0
# todo clear the cookie
0
# redirect to os.environ['PATH_INFO'] with the cookier clearing?
0
- return email, nickname, (admin == 'True')
0
+ return email, nickname, (admin == 'True')
, valid_cookie0
def CreateCookieData(email, nickname, admin):
0
@@ -164,8 +166,10 @@ def LoginRedirect(login_url,
0
outfile.write('Status: 302 Requires login\r\n')
0
outfile.write('Location: %s\r\n\r\n' % redirect_url)
0
-def LoginServiceRedirect(dest_url, endpoint, outfile):
0
- redirect_url = '%s?%s=%s' % (endpoint, CONTINUE_PARAM, urllib.quote(dest_url))
0
+def LoginServiceRedirect(dest_url, endpoint, ah_url, outfile):
0
+ redirect_url = '%s?%s=%s' % (endpoint,
0
+ urllib.quote('%s?%s=%s' %(ah_url,CONTINUE_PARAM,dest_url)))
0
outfile.write('Status: 302 Redirecting to login service URL\r\n')
0
outfile.write('Location: %s\r\n' % redirect_url)
0
@@ -182,14 +186,14 @@ def Logout(continue_url, outfile):
0
-def LoginFromAuth(token, continue_url, auth_endpoint,
outfile):
0
+def LoginFromAuth(token, continue_url, auth_endpoint,
host, outfile):
0
"""Uses the auth token to fetch the userdata from appdrop, then sets the cookie"""
0
- auth_url = "%s?token=%s
" % (auth_endpoint,token)
0
+ auth_url = "%s?token=%s
&app=%s" % (auth_endpoint,token,host)
0
logging.info('fetching: '+auth_url)
0
result = urlfetch.fetch(auth_url);
0
+
logging.info('result: '+result.content)0
if (result.status_code == 200):
0
userinfo = simplejson.loads(result.content)
0
output_headers.append(SetUserInfoCookie(userinfo['email'], userinfo['nickname'], userinfo['admin']))
0
@@ -205,7 +209,13 @@ def LoginFromAuth(token, continue_url, auth_endpoint, outfile):
0
"""Runs the login and logout CGI redirector script."""
0
form = cgi.FieldStorage()
0
- login_url = os.environ['PATH_INFO']
0
+ ah_path = os.environ['PATH_INFO']
0
+ host = 'http://'+os.environ['SERVER_NAME']
0
+ if os.environ['SERVER_PORT'] != '80':
0
+ host = host + ":" + os.environ['SERVER_PORT']
0
+ ah_login_url = host+ah_path
0
action = form.getfirst(ACTION_PARAM)
0
@@ -220,9 +230,9 @@ def main():
0
if action.lower() == LOGOUT_ACTION.lower():
0
Logout(continue_url, sys.stdout)
0
- LoginServiceRedirect(continue_url, login_service_endpoint,
sys.stdout)
0
+ LoginServiceRedirect(continue_url, login_service_endpoint,
ah_login_url, sys.stdout)
0
- LoginFromAuth(auth_token, continue_url, auth_endpoint,
sys.stdout)
0
+ LoginFromAuth(auth_token, continue_url, auth_endpoint,
host, sys.stdout)
Comments
No one has commented yet.