source: cowsclient/trunk/cowsclient/controllers/securitylogin.py @ 6191

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cowsclient/trunk/cowsclient/controllers/securitylogin.py@6191
Revision 6191, 1.2 KB checked in by domlowe, 11 years ago (diff)

modifying cowsclient so that client does not need to use security wsgi pipeline, all security is done on server

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')
Note: See TracBrowser for help on using the repository browser.