Changeset 5984


Ignore:
Timestamp:
10/11/09 13:18:44 (10 years ago)
Author:
pjkersha
Message:

Adding Genshi based templating plugins for OpenID Provider and Relying Party.

Location:
TI12-security/trunk/python
Files:
41 added
6 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg_security_saml/saml/xml/etree.py

    r5982 r5984  
    3838    import cElementTree, ElementTree 
    3939 
    40 from saml.saml2.core import SAMLObject, Attribute, AttributeStatement, \ 
    41     AuthnStatement, AuthzDecisionStatement, Assertion, Conditions, \ 
    42     AttributeValue, AttributeQuery, Subject, NameID, Issuer, Response, \ 
    43     Status, StatusCode, StatusMessage, StatusDetail, Advice, \ 
    44     XSStringAttributeValue, XSGroupRoleAttributeValue 
     40from saml.saml2.core import (SAMLObject, Attribute, AttributeStatement,  
     41                             AuthnStatement, AuthzDecisionStatement, Assertion, 
     42                             Conditions, AttributeValue, AttributeQuery,  
     43                             Subject, NameID, Issuer, Response, Status,  
     44                             StatusCode, StatusMessage, StatusDetail, Advice,  
     45                             XSStringAttributeValue)  
     46                              
    4547from saml.common import SAMLVersion 
    4648from saml.common.xml import SAMLConstants 
     
    4850from saml.xml import XMLTypeParseError, UnknownAttrProfile 
    4951from saml.utils import SAMLDateTime 
     52 
     53from ndg.security.common.saml.esg import XSGroupRoleAttributeValue 
    5054 
    5155 
  • TI12-security/trunk/python/ndg_security_server/ndg/security/server/wsgi/openid/provider/__init__.py

    r5870 r5984  
    12671267        Exception.__init__(self, msg, **kw) 
    12681268         
     1269         
    12691270class RenderingInterfaceInitError(RenderingInterfaceError): 
    12701271    """Error with initialisation of RenderingInterface.  Raise from __init__""" 
    12711272    errorMsg = "RenderingInterface initialisation error" 
    12721273     
     1274     
    12731275class RenderingInterfaceConfigError(RenderingInterfaceError): 
    12741276    """Error with configuration settings.  Raise from __init__""" 
    12751277    errorMsg = "RenderingInterface configuration error"     
     1278     
    12761279     
    12771280class RenderingInterface(object): 
     
    12971300     
    12981301    @type tmplYadis: basestring""" 
    1299     
     1302     
     1303    # Enable slot support for derived classes if they require it  
     1304    __slots__ = ('_authN', 'base_url', 'urls', 'charset') 
     1305     
    13001306    tmplServerYadis = """\ 
    13011307<?xml version="1.0" encoding="UTF-8"?> 
     
    13511357        self.charset = '' 
    13521358     
    1353      
    13541359    def serverYadis(self, environ, start_response): 
    13551360        '''Render Yadis info for ID Select mode request 
     
    13731378        return response 
    13741379 
    1375  
    13761380    def yadis(self, environ, start_response): 
    13771381        """Render Yadis document containing user URL 
     
    14051409        return response 
    14061410     
    1407  
    14081411    def identityPage(self, environ, start_response): 
    14091412        """Render the identity page. 
     
    14221425                        ('Content-length', str(len(response)))]) 
    14231426        return response 
    1424      
    1425          
     1427          
    14261428    def login(self, environ, start_response, 
    14271429              success_to=None, fail_to=None, msg=''): 
     
    14541456        return response 
    14551457 
    1456  
    14571458    def mainPage(self, environ, start_response): 
    14581459        """Rendering the main page. 
  • TI12-security/trunk/python/ndg_security_server/ndg/security/server/wsgi/openid/provider/axinterface/csv.py

    r5786 r5984  
    3636        "attributeMap", 
    3737    ) 
     38    __slots__ += tuple(["_CSVFileAXInterface__%s" % n for n in __slots__]) 
     39    del n 
     40     
    3841    IDENTITY_URI_SESSION_KEYNAME = \ 
    3942                        OpenIDProviderMiddleware.IDENTITY_URI_SESSION_KEYNAME 
  • TI12-security/trunk/python/ndg_security_server/ndg/security/server/wsgi/openid/provider/axinterface/sqlalchemy_ax.py

    r5880 r5984  
    3333    ATTRIBUTE_NAMES_OPTNAME = "attributeNames" 
    3434    IDENTITY_URI_TMPL_OPTNAME = 'identityUriTemplate' 
     35    SQLQUERY_USERID_KEYNAME = 'username' 
    3536     
    3637    __slots__ = ( 
     
    202203                         requestedAttributeURI) 
    203204 
    204     def _makeDbConnection(self): 
    205         """Create a database connection 
    206         @rtype: SQLAlchemy database engine 
    207         @return: database connection object 
    208         """          
    209         try: 
    210             dbEngine = create_engine(self.connectionString) 
    211         except ImportError, e: 
    212             raise AuthNInterfaceConfigError("Missing database engine for " 
    213                                             "SQLAlchemy: %s" % e) 
    214         return dbEngine.connect() 
     205        return  
    215206 
    216207    def _attributeQuery(self, username): 
     
    220211        they refer to 
    221212        ''' 
     213         
     214        if self.connectionString is None: 
     215            raise AuthNInterfaceConfigError('No "connectionString" setting ' 
     216                                            'has been made') 
     217        dbEngine = create_engine(self.connectionString) 
     218         
    222219        try: 
    223             queryInputs = dict(username=username) 
     220            queryInputs = { 
     221                SQLAlchemyAXInterface.SQLQUERY_USERID_KEYNAME: username 
     222            } 
    224223            query = Template(self.sqlQuery).substitute(queryInputs) 
     224             
     225        except KeyError, e: 
     226            raise AuthNInterfaceConfigError("Invalid key for attribute query " 
     227                                            "string.  The valid key is %r" %  
     228                                SQLAlchemyAXInterface.SQLQUERY_USERID_KEYNAME) 
     229             
     230        try: 
     231            dbEngine.connect() 
    225232            result = connection.execute(query) 
    226233 
    227         except exc.ProgrammingError: 
    228             raise AuthNInterfaceRetrieveError("Error with SQL Syntax: %s" % 
     234        except (exc.ProgrammingError, exc.OperationalError): 
     235            raise AuthNInterfaceRetrieveError("SQL error: %s" % 
    229236                                              traceback.format_exc()) 
    230237        finally: 
  • TI12-security/trunk/python/ndg_security_server/ndg/security/server/wsgi/saml/__init__.py

    r5703 r5984  
    1616from xml.etree import ElementTree 
    1717 
    18 from saml.saml2.core import Response, Assertion, Attribute, AttributeValue, \ 
    19     AttributeStatement, SAMLVersion, Subject, NameID, Issuer, AttributeQuery, \ 
    20     XSStringAttributeValue, XSGroupRoleAttributeValue, Conditions, Status, \ 
    21     StatusCode 
     18from saml.saml2.core import (Response, Assertion, Attribute, AttributeValue,  
     19                             AttributeStatement, SAMLVersion, Subject, NameID,  
     20                             Issuer, AttributeQuery, XSStringAttributeValue,  
     21                             Conditions, Status, StatusCode) 
    2222     
    2323from saml.common.xml import SAMLConstants 
    2424from saml.xml import UnknownAttrProfile 
    25 from saml.xml.etree import AssertionElementTree, AttributeQueryElementTree, \ 
    26     ResponseElementTree, XSGroupRoleAttributeValueElementTree, QName 
    27  
     25from saml.xml.etree import (AssertionElementTree, AttributeQueryElementTree,  
     26                            ResponseElementTree, QName) 
     27 
     28from ndg.security.common.saml.esg import XSGroupRoleAttributeValue 
     29from ndg.security.common.saml.esg.xml.etree import ( 
     30                                        XSGroupRoleAttributeValueElementTree) 
    2831from ndg.security.common.soap.etree import SOAPEnvelope 
    2932from ndg.security.common.utils.etree import prettyPrint 
    3033from ndg.security.server.wsgi import NDGSecurityPathFilter 
    3134from ndg.security.server.wsgi.soap import SOAPMiddleware 
     35 
    3236 
    3337class SOAPAttributeInterfaceMiddlewareError(Exception): 
  • TI12-security/trunk/python/ndg_security_test/ndg/security/test/integration/authz_lite/securityservices.ini

    r5786 r5984  
    125125openid.relyingparty.caCertDirPath = %(testConfigDir)s/ca 
    126126openid.relyingparty.providerWhitelistFilePath = 
    127 openid.relyingparty.signinInterfaceMiddlewareClass = ndg.security.server.wsgi.openid.relyingparty.signin_interface.buffet.BuffetSigninTemplate 
    128 openid.relyingparty.signinInterface.templatePackage = ndg.security.server.wsgi.openid.relyingparty.signin_interface.buffet.templates 
     127openid.relyingparty.signinInterfaceMiddlewareClass = ndg.security.server.wsgi.openid.relyingparty.signin_interface.genshi.GenshiSigninTemplate 
    129128openid.relyingparty.signinInterface.staticContentRootDir = %(here)s/openidrelyingparty/public 
    130129openid.relyingparty.signinInterface.baseURL = %(openid.relyingparty.baseURL)s 
     
    231230openid.provider.trace=False 
    232231openid.provider.consumer_store_dirpath=%(here)s/openidprovider 
    233 openid.provider.renderingClass=ndg.security.server.wsgi.openid.provider.renderinginterface.buffet.BuffetRendering 
     232openid.provider.renderingClass=ndg.security.server.wsgi.openid.provider.renderinginterface.genshi.GenshiRendering 
    234233#openid.provider.renderingClass=ndg.security.server.wsgi.openid.provider.DemoRenderingInterface 
    235  
    236 openid.provider.rendering.templateType = kid 
    237 openid.provider.rendering.templateRoot = ndg.security.server.wsgi.openid.provider.renderinginterface.buffet.templates 
    238 openid.provider.rendering.kid.assume_encoding= utf-8 
    239 openid.provider.rendering.kid.encoding = utf-8 
    240234 
    241235# Layout 
Note: See TracChangeset for help on using the changeset viewer.