Changeset 7142 for TI12-security/trunk


Ignore:
Timestamp:
30/06/10 16:39:36 (9 years ago)
Author:
pjkersha
Message:

Incomplete - task 2: XACML-Security Integration

  • testing query interface middleware
Location:
TI12-security/trunk/ndg_saml
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/ndg_saml/.pydevproject

    r7140 r7142  
    55<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property> 
    66<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Python2.6</pydev_property> 
     7<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> 
     8<path>/ndg_saml</path> 
     9</pydev_pathproperty> 
     10<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH"> 
     11<path>/home/pjkersha/workspace/ndg_soap</path> 
     12</pydev_pathproperty> 
    713</pydev_project> 
  • TI12-security/trunk/ndg_saml/ndg/saml/saml2/binding/soap/server/wsgi/__init__.py

    r7130 r7142  
     1"""NDG SAML 
     2 
     3WSGI Package for SAML SOAP Binding  
     4 
     5NERC DataGrid Project 
     6""" 
     7__author__ = "P J Kershaw" 
     8__date__ = "30/06/10" 
     9__copyright__ = "(C) 2010 Science and Technology Facilities Council" 
     10__license__ = "http://www.apache.org/licenses/LICENSE-2.0" 
     11__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     12__revision__ = '$Id:$' 
  • TI12-security/trunk/ndg_saml/ndg/saml/saml2/binding/soap/server/wsgi/queryinterface.py

    r7130 r7142  
    88__copyright__ = "(C) 2010 Science and Technology Facilities Council" 
    99__contact__ = "Philip.Kershaw@stfc.ac.uk" 
    10 __revision__ = "$Id:$" 
     10__revision__ = "$Id$" 
    1111__license__ = "http://www.apache.org/licenses/LICENSE-2.0" 
    1212import logging 
     
    1616from uuid import uuid4 
    1717from datetime import datetime, timedelta 
    18 from xml.etree import ElementTree 
    19  
     18 
     19from ndg.soap.server.wsgi.middleware import SOAPMiddleware 
     20from ndg.soap.etree import SOAPEnvelope 
     21from ndg.soap.utils import str2Bool 
     22 
     23from ndg.saml.utils.factory import importModuleObject 
     24from ndg.saml.xml import UnknownAttrProfile 
    2025from ndg.saml.common import SAMLVersion 
    2126from ndg.saml.utils import SAMLDateTime 
    2227from ndg.saml.saml2.core import (Response, Status, StatusCode, StatusMessage,  
    2328                                 Issuer)  
    24 from ndg.saml.xml import UnknownAttrProfile 
    25  
    26 from ndg.security.common.utils import str2Bool 
    27 from ndg.security.common.utils.factory import importModuleObject 
    28 from ndg.security.common.soap.etree import SOAPEnvelope 
    29 from ndg.security.common.saml_utils.esg import XSGroupRoleAttributeValue 
    30 from ndg.security.common.saml_utils.esg.xml.etree import ( 
    31                                         XSGroupRoleAttributeValueElementTree) 
    32 from ndg.security.server.wsgi import NDGSecurityPathFilter 
    33 from ndg.soap.server.wsgi import SOAPMiddleware 
    3429 
    3530 
     
    4237 
    4338 
    44 class SOAPQueryInterfaceMiddleware(SOAPMiddleware, NDGSecurityPathFilter): 
     39class SOAPQueryInterfaceMiddleware(SOAPMiddleware): 
    4540    """Implementation of SAML 2.0 SOAP Binding for Query/Request Binding 
    4641     
     
    5651    """ 
    5752    log = logging.getLogger('SOAPQueryInterfaceMiddleware') 
    58     PATH_OPTNAME = "pathMatchList" 
     53    PATH_OPTNAME = "mountPath" 
    5954    QUERY_INTERFACE_KEYNAME_OPTNAME = "queryInterfaceKeyName" 
    6055    DEFAULT_QUERY_INTERFACE_KEYNAME = ("ndg.security.server.wsgi.saml." 
     
    8681        @param app: next middleware application in the chain  
    8782        '''      
    88         NDGSecurityPathFilter.__init__(self, app, None) 
     83        super(SOAPQueryInterfaceMiddleware, self).__init__(app, None) 
    8984         
    9085        self._app = app 
     
    9388        cls = SOAPQueryInterfaceMiddleware 
    9489        self.__queryInterfaceKeyName = cls.DEFAULT_QUERY_INTERFACE_KEYNAME 
    95         self.pathMatchList = ['/'] 
     90        self.__mountPath = None 
     91        self.mountPath = ['/'] 
    9692        self.__requestEnvelopeClass = None 
    9793        self.__responseEnvelopeClass = None 
     
    121117        dictionary 
    122118        ''' 
    123         cls = SOAPQueryInterfaceMiddleware 
    124          
    125119        # Override where set in config 
    126120        for name in SOAPQueryInterfaceMiddleware.CONFIG_FILE_OPTNAMES: 
     
    288282                           "SAML Version to enforce for incoming queries.  " 
    289283                           "Defaults to version 2.0") 
    290  
     284         
     285    def _getMountPath(self): 
     286        return self.__mountPath 
     287     
     288    def _setMountPath(self, value): 
     289        ''' 
     290        @type value: basestring 
     291        @param value: URL paths to apply this middleware to. Paths are relative  
     292        to the point at which this middleware is mounted as set in  
     293        environ['PATH_INFO'] 
     294        @raise TypeError: incorrect input type 
     295        ''' 
     296         
     297        if not isinstance(value, basestring): 
     298            raise TypeError('Expecting string type for "mountPath" attribute; ' 
     299                            'got %r' % value) 
     300             
     301        self.__mountPath = value 
     302             
     303    mountPath = property(fget=_getMountPath, 
     304                         fset=_setMountPath, 
     305                         doc='URL path to mount this application equivalent to ' 
     306                             'environ[\'PATH_INFO\'] (Nb. doesn\'t ' 
     307                             'include server domain name or ' 
     308                             'environ[\'SCRIPT_NAME\'] setting') 
     309     
    291310    @classmethod 
    292311    def filter_app_factory(cls, app, global_conf, **app_conf): 
     
    324343                                         "interface") 
    325344     
    326     @NDGSecurityPathFilter.initCall 
    327345    def __call__(self, environ, start_response): 
    328346        """Check for and parse a SOAP SAML Attribute Query and return a 
  • TI12-security/trunk/ndg_saml/ndg/saml/test/binding/soap/__init__.py

    r7140 r7142  
     1"""NDG SAML 
     2 
     3Test SAML Attribute Query Interface 
     4 
     5NERC DataGrid Project 
     6""" 
     7__author__ = "P J Kershaw" 
     8__date__ = "21/08/09" 
     9__copyright__ = "(C) 2009 Science and Technology Facilities Council" 
     10__license__ = "http://www.apache.org/licenses/LICENSE-2.0" 
     11__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     12__revision__ = '$Id:$' 
     13import os 
     14import unittest 
     15import paste.fixture 
     16from paste.deploy import loadapp 
     17 
     18 
     19class TestApp(object): 
     20    """Dummy application to terminate middleware stack containing SAML service 
     21    """ 
     22    def __init__(self, global_conf, **app_conf): 
     23        pass 
     24     
     25    def __call__(self, environ, start_response): 
     26        response = "404 Not Found" 
     27        start_response(response, 
     28                       [('Content-length', str(len(response))), 
     29                        ('Content-type', 'text/plain')]) 
     30                             
     31        return [response] 
     32 
     33 
     34class SoapSamlInterfaceMiddlewareTestCase(unittest.TestCase): 
     35    HERE_DIR = os.path.dirname(os.path.abspath(__file__)) 
     36    CONFIG_FILENAME = 'test.ini' 
     37     
     38    def __init__(self, *args, **kwargs): 
     39        wsgiapp = loadapp('config:%s' % self.__class__.CONFIG_FILENAME,  
     40                          relative_to=self.__class__.HERE_DIR) 
     41         
     42        self.app = paste.fixture.TestApp(wsgiapp) 
     43          
     44        BaseTestCase.__init__(self, *args, **kwargs) 
  • TI12-security/trunk/ndg_saml/ndg/saml/test/binding/soap/authz-decision-interface.ini

    r7140 r7142  
    2121 
    2222[app:TestApp] 
    23 paste.app_factory = ndg.security.test.unit.wsgi.saml:TestApp 
     23paste.app_factory = ndg.saml.test.binding.soap:TestApp 
    2424 
    2525[filter:SAMLSoapAuthzDecisionInterfaceFilter] 
    26 paste.filter_app_factory = ndg.saml.saml2.binding.sopa.server.wsgi.queryinterface:SOAPQueryInterfaceMiddleware.filter_app_factory 
     26paste.filter_app_factory = ndg.saml.saml2.binding.soap.server.wsgi.queryinterface:SOAPQueryInterfaceMiddleware.filter_app_factory 
    2727prefix = saml. 
    28 saml.pathMatchList = /authorisationservice 
     28saml.mountPath = /authorisationservice 
    2929saml.queryInterfaceKeyName = AUTHZ_DECISION_QUERY_FUNC 
    3030saml.deserialise = ndg.saml.xml.etree:AuthzDecisionQueryElementTree.fromXML 
  • TI12-security/trunk/ndg_saml/ndg/saml/test/binding/soap/test_soapauthzdecisioninterface.py

    r7140 r7142  
    1515from cStringIO import StringIO 
    1616 
     17from ndg.soap.etree import SOAPEnvelope 
     18 
    1719from ndg.saml.saml2.core import (SAMLVersion, Subject, NameID, Issuer,  
    1820                                 AuthzDecisionQuery, AuthzDecisionStatement,  
     
    2123from ndg.saml.xml.etree import (AuthzDecisionQueryElementTree,  
    2224                                ResponseElementTree) 
    23  
    24 from ndg.soap.etree import SOAPEnvelope 
    25 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces 
    26 from ndg.security.test.unit.wsgi.saml import SoapSamlInterfaceMiddlewareTestCase 
     25from ndg.saml.test.binding.soap import SoapSamlInterfaceMiddlewareTestCase 
    2726 
    2827 
     
    116115        query.subject = Subject()   
    117116        query.subject.nameID = NameID() 
    118         query.subject.nameID.format = EsgSamlNamespaces.NAMEID_FORMAT 
     117        query.subject.nameID.format = "urn:ndg:saml:test:openid" 
    119118        query.subject.nameID.value = subject 
    120119                                  
Note: See TracChangeset for help on using the changeset viewer.