source: TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/lib/openid_util.py @ 3914

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/lib/openid_util.py@3914
Revision 3914, 1.4 KB checked in by pjkersha, 12 years ago (diff)
  • New ndg.security.common.zsi_util.httpproxy.ProxyHTTPConnection class replaces urllib2client - easier to fit into existing ZSI client framework.
  • Further OpenID integration into Single Sign On Service. User now authenticates OK but patches needed to AuthKit? + need to handle return_to URL dynamically according to page visited before WAYF call.
Line 
1import pylons
2from pylons.templating import Buffet
3from pylons import config
4import sso.lib.helpers as h
5from sso.lib.app_globals import Globals
6
7import logging
8log = logging.getLogger(__name__)
9
10log.debug("Defining MyBuffet for OpenID template ...")
11
12class MyBuffet(Buffet):
13    def _update_names(self, ns):
14        return ns
15
16def_eng = config['buffet.template_engines'][0]
17log.info("def_eng = %s" % def_eng)
18buffet = MyBuffet(
19    def_eng['engine'],
20    template_root=def_eng['template_root'],
21    **def_eng['template_options']
22)
23
24for e in config['buffet.template_engines'][1:]:
25    buffet.prepare(
26        e['engine'],
27        template_root=e['template_root'],
28        alias=e['alias'],
29        **e['template_options']
30    )
31
32class State:
33    pass
34
35c = State()
36c.openid = 'None'
37c.title = "OpenID Login"
38c.xml = ''
39c.providers = {}
40
41log.debug("config=%s" % config)
42def make_template():
43    '''Make kid template for OpenID login - this piggy backs the NDG WAYF'''
44    return buffet.render(
45        template_name="ndg.security.wayf",
46        namespace=dict(h=h, g=config['pylons.g'], c=c)
47    ).replace("%", "%%").replace("SERVER", "%s")
48
49
50def url2user(environ, url):
51    '''Function picked up by authkit.openid.urltouser config setting.  It
52    sets a session from the users OpenID URL following login'''
53
54    username = url.replace('http://', '').replace('https://', '').strip('/').split('/')[-1]
55    return username
Note: See TracBrowser for help on using the repository browser.