source: cowsclient/tags/1.6.0-py2.6/cowsclient/controllers/securitylogin.py @ 7593

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cowsclient/tags/1.6.0-py2.6/cowsclient/controllers/securitylogin.py@7593
Revision 7593, 1.2 KB checked in by astephen, 10 years ago (diff)

Tagged version updated to be compatible with:

  • python 2.6
  • pylons 1.0
Line 
1import logging
2
3from cowsclient.lib.base import *
4from paste.request import parse_querystring
5import urllib2
6
7log = logging.getLogger(__name__)
8
9class SecurityloginController(BaseController):
10    def index(self):
11        if 'ndg.security.auth' in request.cookies.keys():
12            return '<html><head></head><body onload="window.close()"></body></html>'
13        else:
14            #get login credentials
15            inputs=dict(parse_querystring(request.environ))
16            securedResource=inputs['endpoint']
17            try:
18                u=urllib2.urlopen(securedResource)
19            except urllib2.HTTPError, e:
20                if e.code == 401:
21                    #replace the redirection part of the url with a link to a controller which closes the login window (rather than accessing the WXS resource
22                    serverurl=config['app_conf']['serverurl'] 
23                    loggedinurl='%s/loggedin'%serverurl
24                    c.redirecturl = '%s=%s'%(e.url.split('=')[0],loggedinurl)
25                    #i.e. c.redirecturl="https://ndg3beta.badc.rl.ac.uk/verify?ndg.security.r=http%253A%252F%252Flocalhost:5005%252Floggedin"
26                    return render('redirecting.html')
Note: See TracBrowser for help on using the repository browser.