Ignore:
Timestamp:
15/08/08 14:53:33 (12 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.