Changeset 7292 for TI12-security


Ignore:
Timestamp:
06/08/10 12:44:04 (9 years ago)
Author:
pjkersha
Message:

Incomplete - task 12: ESG Yadis identity service discovery

  • Altered Python OpenID Provider adding support for custom XRDS document via Gensho templating. This enables service endpoints other than the default OpenID one to be advertised by the Yadis doc incl. the Attribute Service which is now required for ESG.
Location:
TI12-security/trunk/NDGSecurity/python
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/openid/provider/__init__.py

    r7077 r7292  
    16281628    xmlns="xri://$xrd*($v*2.0)"> 
    16291629  <XRD> 
    1630  
    16311630    <Service priority="0"> 
    16321631      <Type>%(openid20type)s</Type> 
    16331632      <URI>%(endpoint_url)s</URI> 
    16341633    </Service> 
    1635  
    16361634  </XRD> 
    16371635</xrds:XRDS> 
     
    16441642    xmlns="xri://$xrd*($v*2.0)"> 
    16451643  <XRD> 
    1646  
    16471644    <Service priority="0"> 
    16481645      <Type>%(openid20type)s</Type> 
     
    16511648      <LocalID>%(user_url)s</LocalID> 
    16521649    </Service> 
    1653  
    16541650  </XRD> 
    16551651</xrds:XRDS>"""     
  • TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/openid/provider/renderinginterface/genshi/__init__.py

    r7077 r7292  
    4343        'rightAlt', 
    4444        'footerText', 
    45         'helpIcon' 
     45        'helpIcon', 
     46        'tmplServerYadis', 
     47        'tmplYadis' 
    4648    ) 
     49     
     50    # Make a set of defaults with specific settings for the Yadis templates  
     51    # based on parent class class variables 
     52    PROPERTY_DEFAULTS = {}.fromkeys(PROPERTY_NAMES, '') 
     53    PROPERTY_DEFAULTS['tmplServerYadis'] = RenderingInterface.tmplServerYadis 
     54    PROPERTY_DEFAULTS['tmplYadis'] = RenderingInterface.tmplYadis 
     55     
    4756    ATTR_NAMES = ( 
    4857        'title',  
     
    6978    MAIN_PAGE_TMPL_NAME = 'main.html' 
    7079    ERROR_PAGE_TMPL_NAME = 'error.html' 
     80    SERVER_YADIS_TMPL_NAME = 'serveryadis.xml' 
     81    YADIS_TMPL_NAME = 'yadis.xml' 
    7182     
    7283    # Approve and reject submit HTML input types for the Relying Party Approval  
     
    7687 
    7788    DEFAULT_TEMPLATES_DIR = path.join(path.dirname(__file__), 'templates') 
    78      
     89 
     90    
    7991    def __init__(self, *arg, **opt): 
    8092        '''Extend RenderingInterface to include config and set-up for Genshi 
     
    88100         
    89101        # Initialise attributes 
    90         for i in GenshiRendering.PROPERTY_NAMES: 
    91             setattr(self, i, '') 
     102        for i in self.__class__.PROPERTY_NAMES: 
     103            setattr(self, i, self.__class__.PROPERTY_DEFAULTS[i]) 
    92104          
    93105        # Update from keywords    
     
    265277                      doc="Genshi TemplateLoader instance")   
    266278           
    267     def _render(self, templateName, c=None, **kw): 
     279    def _render(self, templateName, method='html', doctype='html', c=None, **kw): 
    268280        '''Wrapper for Genshi template rendering 
    269281        @type templateName: basestring 
     
    282294         
    283295        tmpl = self.loader.load(templateName) 
    284         rendering = tmpl.generate(**kw).render('html', doctype='html') 
     296        rendering = tmpl.generate(**kw).render(method=method, doctype=doctype) 
    285297         
    286298        return rendering 
     
    311323                         user_url=user_url) 
    312324         
    313         response = RenderingInterface.tmplYadis % yadisDict 
     325        response = self._render(self.__class__.YADIS_TMPL_NAME,  
     326                                method='xml', 
     327                                doctype=None, 
     328                                **yadisDict) 
    314329      
    315330        start_response('200 OK', 
     
    317332                        ('Content-length', str(len(response)))]) 
    318333        return response 
    319   
     334     
     335    def serverYadis(self, environ, start_response): 
     336        '''Render Yadis info for ID Select mode request - Override base  
     337        implementation to enable custom XRDS document setting 
     338         
     339        @type environ: dict 
     340        @param environ: dictionary of environment variables 
     341        @type start_response: callable 
     342        @param start_response: WSGI start response function.  Should be called 
     343        from this method to set the response code and HTTP header content 
     344        @rtype: basestring 
     345        @return: WSGI response 
     346        ''' 
     347        endpoint_url = self.urls['url_openidserver'] 
     348        _dict = { 
     349            'openid20type': discover.OPENID_IDP_2_0_TYPE, 
     350            'endpoint_url': endpoint_url 
     351        } 
     352         
     353        response = self._render(self.__class__.SERVER_YADIS_TMPL_NAME,  
     354                                method='xml', 
     355                                doctype=None, 
     356                                **_dict) 
     357              
     358        start_response("200 OK", 
     359                       [('Content-type', 'application/xrds+xml'), 
     360                        ('Content-length', str(len(response)))]) 
     361        return response  
     362     
    320363    def login(self, environ, start_response, success_to=None, fail_to=None,  
    321364              msg=''): 
  • TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/integration/authz_lite/securityservices.ini

    r7153 r7292  
    360360# SAML SOAP Binding to the Attribute Authority 
    361361[filter:AttributeAuthoritySamlSoapBindingFilter] 
    362 paste.filter_app_factory = ndg.security.server.wsgi.saml:SOAPQueryInterfaceMiddleware.filter_app_factory 
     362paste.filter_app_factory = ndg.saml.saml2.binding.soap.server.wsgi.queryinterface:SOAPQueryInterfaceMiddleware.filter_app_factory 
    363363prefix = saml.soapbinding. 
    364364 
Note: See TracChangeset for help on using the changeset viewer.