Changeset 4125


Ignore:
Timestamp:
15/08/08 14:53:33 (11 years ago)
Author:
pjkersha
Message:

ndg.security.server.wsgi.openid_provider: fixes for setting custom paths
ndg.security.server.pylons.container: generic pylons project to contain security services: OpenID Provider, Attribute Authority and Session Manager

Location:
TI12-security/trunk/python
Files:
455 added
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/Tests/openid-provider/op/op/templates/ndg/security/decidePage.kid

    r4122 r4125  
    22    <head> 
    33            <replace py:replace="pagehead()"/> 
    4         <script src="$g.server/js/wmsc.js"></script> 
    5         <script src="$g.server/js/prototype.js"></script> 
     4        <script src="${g['server']}/js/wmsc.js"></script> 
     5        <script src="${g['server']}/js/prototype.js"></script> 
    66        <script src="http://www.openlayers.org/api/OpenLayers.js"></script> 
    7         <script src="$g.server/js/openlayers-x.js"/> 
    8         <script src="$g.server/js/dimensionControl.js"/> 
    9         <script src="$g.server/js/mapControl.js"/> 
     7        <script src="${g['server']}/js/openlayers-x.js"/> 
     8        <script src="${g['server']}/js/dimensionControl.js"/> 
     9        <script src="${g['server']}/js/mapControl.js"/> 
    1010    </head> 
    1111    <body> 
  • TI12-security/trunk/python/Tests/openid-provider/op/op/templates/ndg/security/ndgPage.kid

    r4122 r4125  
    1010        function is needed to avoid escaping the < character --> 
    1111        ${XML(h.javascript_include_tag(builtins=True))} 
    12         <script type="text/javascript" src="$g.server/js/toggleDiv.js"/> 
     12        <script type="text/javascript" src="${g['server']}/js/toggleDiv.js"/> 
    1313 
    14         <link media="all, screen" href="$g.server/layout/ndg2.css" type="text/css" rel="stylesheet"/> 
    15         <link rel="icon" type="image/ico" href="$g.server/layout/favicon.jpg" /> 
     14        <link media="all, screen" href="${g['server']}/layout/ndg2.css" type="text/css" rel="stylesheet"/> 
     15        <link rel="icon" type="image/ico" href="${g['server']}/layout/favicon.jpg" /> 
    1616    </head> 
    1717 
    1818    <div py:def="header()"> 
    1919        <div id="header"/> 
    20         <div id="logo"><img src="$g.LeftLogo" alt="$g.LeftAlt" /></div> 
     20        <div id="logo"><img src="${g['LeftLogo']}" alt="${g['LeftAlt']}" /></div> 
    2121    </div> 
    2222     
     
    9999        <span> 
    100100            <a href="javascript:;" title="Toggle help" onclick="toggleDiv(1,'$value','shown','hidden','div'); return false;"> 
    101             <img src="$g.helpIcon" alt="Toggle help" class="helpicon"/></a> 
     101            <img src="${g['helpIcon']}" alt="Toggle help" class="helpicon"/></a> 
    102102       
    103103        </span> 
  • TI12-security/trunk/python/ndg.security.server/ndg/security/server/pylons/container/config/environment.py

    r4123 r4125  
    2323    config.init_app(global_conf, app_conf,  
    2424                    package='ndg.security.server.pylons.container', 
    25                     template_engine='mako', paths=paths) 
     25                    template_engine='kid', paths=paths) 
    2626 
    2727    config['routes.map'] = make_map() 
  • TI12-security/trunk/python/ndg.security.server/ndg/security/server/pylons/container/config/middleware.py

    r4123 r4125  
    1111from pylons.wsgiapp import PylonsApp 
    1212 
    13 from ndg.security.server.pylons.container.config.environment import load_environment 
     13from ndg.security.server.pylons.container.config.environment import \ 
     14    load_environment 
     15     
     16from ndg.security.server.wsgi.openid_provider import OpenIDProviderMiddleware 
     17from beaker.middleware import SessionMiddleware 
     18import authkit.authenticate 
     19 
    1420 
    1521def make_app(global_conf, full_stack=True, **app_conf): 
     
    3844 
    3945    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 
     46    app = OpenIDProviderMiddleware(app, app_conf) 
     47    app = authkit.authenticate.middleware(app, app_conf) 
     48    app = SessionMiddleware(app) 
    4049 
    4150    if asbool(full_stack): 
  • TI12-security/trunk/python/ndg.security.server/ndg/security/server/pylons/development.ini

    r4123 r4125  
    1111error_email_from = paste@localhost 
    1212 
     13# Layout 
     14server = http://localhost:5000 
     15LeftLogo = %(server)s/layout/NERC_Logo.gif 
     16LeftAlt = Natural Environment Research Council 
     17ndgLink = http://ndg.nerc.ac.uk/ 
     18ndgImage = %(server)s/layout/ndg_logo_circle.gif 
     19disclaimer =  
     20stfcLink = http://ceda.stfc.ac.uk/ 
     21stfcImage = %(server)s/layout/stfc-circle-sm.gif 
     22helpIcon = %(server)s/layout/icons/help.png 
     23 
    1324[server:main] 
    1425use = egg:Paste#http 
     
    1728 
    1829[app:main] 
     30#use = egg:ndg_security_server 
    1931use = egg:container 
    2032full_stack = true 
     
    2234beaker.session.key = container 
    2335beaker.session.secret = somesecret 
     36 
     37authkit.setup.method = form, cookie 
     38authkit.form.authenticate.user.data = visitor:open_sesame 
     39authkit.cookie.secret = secret string 
    2440 
    2541# If you'd like to fine-tune the individual locations of the cache data dirs 
     
    3450#set debug = false 
    3551 
     52# OpenID Provider 
     53#openid_provider.path.openidserver=/openidserver 
     54#openid_provider.path.login=/login 
     55#openid_provider.path.loginsubmit=/loginsubmit 
     56#openid_provider.path.id=/id 
     57#openid_provider.path.yadis=/yadis 
     58#openid_provider.path.serveryadis=/serveryadis 
     59#openid_provider.path.allow=/allow 
     60#openid_provider.path.decide=/decide 
     61#openid_provider.path.mainpage=/ 
     62 
     63openid_provider.path.openidserver=/openid/openidserver 
     64openid_provider.path.login=/openid/login 
     65openid_provider.path.loginsubmit=/openid/loginsubmit 
     66openid_provider.path.id=/openid/id 
     67openid_provider.path.yadis=/openid/yadis 
     68openid_provider.path.serveryadis=/openid/serveryadis 
     69openid_provider.path.allow=/openid/allow 
     70openid_provider.path.decide=/openid/decide 
     71openid_provider.path.mainpage=/openid 
     72openid_provider.session_middleware=beaker.session  
     73openid_provider.base_url=http://localhost:5000 
     74openid_provider.consumer_store_dirpath=./ 
     75openid_provider.charset=None 
     76openid_provider.trace=False 
     77openid_provider.renderingClass=ndg.security.server.pylons.container.lib.openid_provider_util.OpenIDProviderKidRendering 
     78openid_provider.getSRegData= 
    3679 
    3780# Logging configuration 
    3881[loggers] 
    39 keys = root, container 
     82keys = root, container, ndg 
    4083 
    4184[handlers] 
     
    5497qualname = container 
    5598 
     99[logger_ndg] 
     100level = DEBUG 
     101handlers = 
     102qualname = ndg 
     103 
    56104[handler_console] 
    57105class = StreamHandler 
     
    61109 
    62110[formatter_generic] 
    63 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s 
     111format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s 
    64112datefmt = %H:%M:%S 
     113 
  • TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/openid_provider.py

    r4123 r4125  
    99""" 
    1010__author__ = "P J Kershaw" 
    11 __date__ = "27/05/08" 
     11__date__ = "01/08/08" 
    1212__copyright__ = "(C) 2008 STFC & NERC" 
    1313__contact__ = "P.J.Kershaw@rl.ac.uk" 
     
    5959     
    6060    defPaths=dict([(k,v) for k,v in defKw.items() if k.startswith('path_')]) 
    61     method = dict([(v, k.replace('path_', 'do_')) for k,v in defPaths.items()]) 
    6261      
    6362    def __init__(self, app, app_conf=None, prefix='openid_provider.', **kw): 
     
    107106        log.debug("opt=%r", opt)         
    108107 
    109         # Paths relative to base URL 
    110         self.paths = dict([(k, opt[k]) \ 
     108        # Paths relative to base URL - Nb. remove trailing '/' 
     109        self.paths = dict([(k, opt[k].rstrip('/')) \ 
    111110                           for k in OpenIDProviderMiddleware.defPaths]) 
    112111         
     
    119118        self.urls = dict([(k.replace('path_', 'url_'), self.base_url+v) \ 
    120119                          for k,v in self.paths.items()]) 
     120 
     121        self.method = dict([(v, k.replace('path_', 'do_')) \ 
     122                            for k,v in self.paths.items()]) 
    121123 
    122124        self.session_middleware = opt['session_middleware'] 
     
    172174            ) 
    173175 
    174         self.path = environ.get('PATH_INFO') 
     176        self.path = environ.get('PATH_INFO').rstrip('/') 
    175177        self.environ = environ 
    176178        self.start_response = start_response 
     
    178180        self._renderer.session = self.session 
    179181         
    180         # Strip trailing slashes 
    181         if self.path[-1] == '/': 
    182             self.path = self.path[:-1] 
    183              
    184         # Match against the first level in the path only to allow for the 'id' 
    185         # and 'yadis' cases where a sub-level could contain a user ID 
    186182        if self.path in (self.paths['path_id'], self.paths['path_yadis']): 
    187183            log.debug("No user id given in URL %s" % self.path) 
     184             
     185            # Disallow identifier and yadis URIs where no ID was specified 
    188186            return self.app(environ, start_response) 
    189187             
     
    191189           self.path.startswith(self.paths['path_yadis']): 
    192190             
    193             pathMatch = '/' + self.path[1:].split('/')[0] 
     191            # Match against path minus ID as this is not known in advance             
     192            pathMatch = self.path[:self.path.rfind('/')] 
    194193        else: 
    195194            pathMatch = self.path 
     
    561560    def renderIdentityPage(self, environ): 
    562561        """Render the identity page.""" 
    563         path = environ.get('PATH_INFO') 
     562        path = environ.get('PATH_INFO').rstrip('/') 
     563        username = path[len(self.paths['path_id'])+1:] 
    564564         
    565565        link_tag = '<link rel="openid.server" href="%s">' % \ 
Note: See TracChangeset for help on using the changeset viewer.