Changeset 6861 for TI12-security/trunk/NDGSecurity
- Timestamp:
- 11/05/10 13:30:09 (11 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python
- Files:
-
- 6 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/.pydevproject
r6686 r6861 3 3 4 4 <pydev_project> 5 <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER"> Default</pydev_property>5 <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Python2.6</pydev_property> 6 6 <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property> 7 7 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> … … 14 14 <path>/home/pjkersha/workspace/MyProxyClient</path> 15 15 <path>/home/pjkersha/workspace/AuthKit/trunk</path> 16 <path>/home/pjkersha/workspace/NDG_XACML</path> 16 17 </pydev_pathproperty> 17 18 </pydev_project> -
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/X509.py
r6557 r6861 15 15 import types 16 16 import re 17 import os 18 import errno 17 19 18 20 # Handle not before and not after strings … … 589 591 nValidated = 0 590 592 issuerX509Cert = None 591 while nValidated < n2Validate: 593 while nValidated < n2Validate: 592 594 issuerX509Cert = None 593 595 issuerDN = x509Cert2Verify.issuer … … 642 644 break 643 645 644 if issuerX509Cert: 646 if issuerX509Cert: 645 647 if not x509Cert2Verify.verify(issuerX509Cert.pubKey): 646 648 X509CertInvalidSignature('Signature is invalid for cert. "%s"' % … … 899 901 900 902 try: 901 # dnFields = dn.split(self.__separator)902 # if len(dnFields) < 2:903 # raise X500DNError("Error parsing DN string: \"%s\"" % dn)904 #905 #906 # # Split fields into key/value and also filter null fields if907 # # found e.g. a leading '/' in the DN would yield a null field908 # # when split909 #910 # items = [field.split('=') for field in dnFields if field]911 903 dnFields = X500DN.PARSER_RE.split(dn) 912 904 if len(dnFields) < 2: -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/attributeauthority.py
r6721 r6861 96 96 dictionary 97 97 ''' 98 app = AttributeAuthorityMiddleware(app)98 app = cls(app) 99 99 app.initialise(global_conf, **app_conf) 100 100 -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/authzservice.py
r6617 r6861 15 15 from uuid import uuid4 16 16 17 # SAML authorisation decision query interface 17 18 from ndg.saml.saml2.core import (Response, AuthzDecisionStatement, Assertion, 18 19 Action, DecisionType, SAMLVersion, Issuer, … … 20 21 Subject, Conditions) 21 22 22 from ndg.security.common.utils.factory import importModuleObject23 from ndg.security.common.authz import Subject as PDPSubject24 from ndg.security.common.authz.msi import Response as PDPResponse25 from ndg.security.common.authz.msi import Policy, PDP, Request, Resource26 23 from ndg.security.common.authz.pip.esginterface import PIP 24 25 # XACML Policy Decision Point 26 from ndg.xacml.parsers.etree.factory import ReaderFactory 27 from ndg.xacml.core.attribute import Attribute 28 from ndg.xacml.core.attributevalue import AttributeValueClassFactory 29 from ndg.xacml.core.context.pdpinterface import PDPInterface 30 from ndg.xacml.core.context.pdp import PDP 31 from ndg.xacml.core.context.request import Request 32 from ndg.xacml.core.context.resource import Resource 33 from ndg.xacml.core import context 27 34 28 35 … … 36 43 37 44 class AuthzServiceMiddleware(object): 38 '''WSGI to add an NDG Security Authorization Service in the environ. This 39 enables multiple WSGI filters to access the same underlying Attribute 40 Authority instance e.g. provide SAML SOAP and WSDL SOAP based interfaces 41 to the same Authorization Service 45 '''WSGI to add an NDG Security Authorization Service in the environ. 42 46 ''' 43 47 DEFAULT_QUERY_IFACE_KEYNAME = \ … … 45 49 46 50 ENVIRON_KEYNAME_QUERY_IFACE_OPTNAME = 'queryInterfaceKeyName' 47 QUERY_IFACE_OPTNAME = 'queryInterface'48 ISSUER_NAME_OPTNAME = 'issuerName'49 ISSUER_FORMAT_OPTNAME = 'issuerFormat'50 CLOCK_SKEW_TOLERANCE_OPTNAME = 'clockSkewTolerance'51 51 ASSERTION_LIFETIME_OPTNAME = 'assertionLifetime' 52 52 … … 54 54 AUTHZ_SRVC_OPTION_DEFAULTS = { 55 55 ENVIRON_KEYNAME_QUERY_IFACE_OPTNAME: DEFAULT_QUERY_IFACE_KEYNAME, 56 ISSUER_NAME_OPTNAME: None,57 ISSUER_FORMAT_OPTNAME: Issuer.X509_SUBJECT,58 56 ASSERTION_LIFETIME_OPTNAME: 60*60*8, # 8 hours as default 59 57 } 60 58 61 POLICY_FILEPATH_OPTNAME = 'filePath' 62 POLICY_CFG_PREFIX = 'policy.' 59 POLICY_FILEPATH_OPTNAME = 'policyFilePath' 63 60 PIP_CFG_PREFIX = 'pip.' 64 61 65 62 __slots__ = ( 66 63 '__policyFilePath', 67 '__ ' + QUERY_IFACE_OPTNAME,64 '__queryInterface', 68 65 '__' + ENVIRON_KEYNAME_QUERY_IFACE_OPTNAME, 69 '__' + CLOCK_SKEW_TOLERANCE_OPTNAME,70 66 '__' + ASSERTION_LIFETIME_OPTNAME, 71 67 '__pdp', 72 68 '_app', 73 '__issuerProxy',74 '__subjectProxy'75 69 ) 76 70 77 71 def __init__(self, app): 78 72 '''Set-up an Authorization Service instance 79 ''' 80 super(AuthzServiceMiddleware, self).__init__(app, {}) 81 73 ''' 82 74 self._app = app 83 75 self.__policyFilePath = None … … 85 77 self.__queryInterface = None 86 78 self.__queryInterfaceKeyName = None 87 self.__clockSkewTolerance = None88 79 self.__assertionLifetime = 0. 89 90 # Proxy object for SAML Response Issuer attributes. By generating a91 # proxy the Response objects inherent attribute validation can be92 # applied to Issuer related config parameters before they're assigned to93 # the response issuer object generated in the authorisation decision94 # query response95 self.__issuerProxy = Issuer()96 80 97 81 def initialise(self, global_conf, prefix='authorizationservice.', … … 118 102 setattr(self, optName, value) 119 103 120 # Address special cases ... 121 authzDecisionQueryIfaceOptName = prefix + cls.QUERY_IFACE_OPTNAME 122 123 # Use decision function set in config but default to the implementation 124 # in this class if no config option is set 125 self.queryInterface = app_conf.get(authzDecisionQueryIfaceOptName, 126 self.createQueryInterface()) 104 self.queryInterface = self.createQueryInterface() 127 105 128 106 # Initialise the Authorisation Policy 129 policyCfgPrefix = prefix + cls.POLICY_CFG_PREFIX 130 policyFilePathOptName = policyCfgPrefix + cls.POLICY_FILEPATH_OPTNAME 131 self.policyFilePath = app_conf.get(policyFilePathOptName) 132 133 policy = Policy.Parse(self.policyFilePath) 107 policyFilePathOptName = prefix + cls.POLICY_FILEPATH_OPTNAME 108 policyFilePath = app_conf.get(policyFilePathOptName) 109 if policyFilePath is None: 110 raise AuthzServiceMiddlewareConfigError('No policy file path set - ' 111 '"policyFilePath" option ' 112 'name') 113 114 self.policyFilePath = policyFilePath 134 115 135 116 # Initialise the Policy Information Point 136 117 pipCfgPrefix = prefix + cls.PIP_CFG_PREFIX 137 118 pip = PIP.fromConfig(app_conf, prefix=pipCfgPrefix) 138 139 # Set default issuer name if not already specified. Nb. format must140 # be overridden141 if pip.attributeQueryBinding.issuerName is None:142 pip.attributeQueryBinding.issuerFormat = self.issuerFormat143 pip.attributeQueryBinding.issuerName = self.issuerName144 119 145 120 # Initialise the PDP reading in the policy 146 self.pdp = PDP (policy, pip)121 self.pdp = PDP.fromPolicySource(self.policyFilePath, ReaderFactory) 147 122 148 123 @classmethod … … 205 180 issuerFormat = property(_getIssuerFormat, _setIssuerFormat, 206 181 doc="Issuer format") 207 208 def _getIssuerName(self): 209 if self.__issuerProxy is None: 210 return None 211 else: 212 return self.__issuerProxy.value 213 214 def _setIssuerName(self, value): 215 if self.__issuerProxy is None: 216 self.__issuerProxy = Issuer() 217 218 self.__issuerProxy.value = value 219 220 issuerName = property(_getIssuerName, _setIssuerName, 221 doc="Name of issuer of SAML Authorisation Query " 222 "Response") 223 224 def _getClockSkewTolerance(self): 225 return self.__clockSkewTolerance 226 227 def _setClockSkewTolerance(self, value): 228 if isinstance(value, (float, int, long)): 229 self.__clockSkewTolerance = timedelta(seconds=value) 230 231 elif isinstance(value, basestring): 232 self.__clockSkewTolerance = timedelta(seconds=float(value)) 233 else: 234 raise TypeError('Expecting float, int, long or string type for ' 235 '"clockSkewTolerance"; got %r' % type(value)) 236 237 clockSkewTolerance = property(fget=_getClockSkewTolerance, 238 fset=_setClockSkewTolerance, 239 doc="Allow a tolerance in seconds for SAML " 240 "Query issueInstant parameter check and " 241 "assertion condition notBefore and " 242 "notOnOrAfter times to allow for clock " 243 "skew") 182 # 183 # def _getIssuerName(self): 184 # if self.__issuerProxy is None: 185 # return None 186 # else: 187 # return self.__issuerProxy.value 188 # 189 # def _setIssuerName(self, value): 190 # if self.__issuerProxy is None: 191 # self.__issuerProxy = Issuer() 192 # 193 # self.__issuerProxy.value = value 194 # 195 # issuerName = property(_getIssuerName, _setIssuerName, 196 # doc="Name of issuer of SAML Authorisation Query " 197 # "Response") 244 198 245 199 _getAssertionLifetime = lambda self: self.__assertionLifetime … … 263 217 264 218 def _setPdp(self, value): 265 if not isinstance(value, PDP ):219 if not isinstance(value, PDPInterface): 266 220 raise TypeError('Expecting %r type for "pdp" attribute; got %r ' 267 'instead' % value)221 'instead' % (PDPInterface, value)) 268 222 269 223 self.__pdp = value … … 317 271 # Nest function within AuthzServiceMiddleware method so that self is 318 272 # in its scope 319 def getAuthzDecision(authzDecisionQuery ):273 def getAuthzDecision(authzDecisionQuery, samlResponse): 320 274 """Authorisation decision function accepts a SAML AuthzDecisionQuery 321 275 and calls the Policy Decision Point returning a response … … 326 280 @return: SAML response containing Authorisation Decision Statement 327 281 """ 328 # Make a request object to pass to the PDP 329 request = Request() 330 request.subject[PDPSubject.USERID_NS 331 ] = authzDecisionQuery.subject.nameID.value 332 333 # IdP Session Manager specific settings: 334 # 335 # The following won't be set if the IdP running the OpenID Provider 336 # hasn't also deployed a Session Manager. In this case, the 337 # Attribute Authority will be queried directly from here without a 338 # remote Session Manager intermediary to cache credentials 339 request.resource[Resource.URI_NS] = authzDecisionQuery.resource 340 341 # TODO: incorporate action(s) requested into PDP request 282 request = self._createXacmlRequestCtx(authzDecisionQuery) 342 283 343 284 # Call the PDP 344 pdpResponse = self.pdp.evaluate(request)285 xacmlResponse = self.pdp.evaluate(request) 345 286 346 287 # Create the SAML Response 347 response = self._createSAMLResponse(authzDecisionQuery)348 authzDecisionStatement = response.assertions[0288 self._createSAMLResponseAssertion(authzDecisionQuery, samlResponse) 289 authzDecisionStatement = samlResponse.assertions[0 349 290 ].authzDecisionStatements[0] 350 291 351 if pdpResponse.status == PDPResponse.DECISION_PERMIT: 292 if (xacmlResponse.results[0].decision == 293 context.result.Decision.PERMIT): 352 294 log.info("AuthzServiceMiddleware.__call__: PDP granted " 353 295 "access for URI path [%s] using policy [%s]", … … 357 299 authzDecisionStatement.decision = DecisionType.PERMIT 358 300 359 elif pdpResponse.status == PDPResponse.DECISION_INDETERMINATE: 301 elif (xacmlResponse.results[0].decision == 302 context.result.Decision.INDETERMINATE): 360 303 log.info("AuthzServiceMiddleware.__call__: PDP returned a " 361 304 "status of [%s] denying access for URI path [%s] " 362 305 "using policy [%s]", 363 pdpResponse.decisionValue2String[pdpResponse.status],306 context.result.Decision.INDETERMINATE, 364 307 authzDecisionQuery.resource, 365 308 self.policyFilePath) … … 371 314 "status of [%s] denying access for URI path [%s] " 372 315 "using policy [%s]", 373 pdpResponse.decisionValue2String[pdpResponse.status],316 context.result.Decision.DENY, 374 317 authzDecisionQuery.resource, 375 318 self.policyFilePath) … … 377 320 authzDecisionStatement.decision = DecisionType.DENY 378 321 379 return response322 return samlResponse 380 323 381 324 return getAuthzDecision 382 383 def _createSAMLResponse(self, authzDecisionQuery): 384 """Helper method to create a SAML Authorisation Decision Response. The 385 resource and actions referred to in the query are set in the 386 Authorization Decision Statement, no decision is set 387 388 @param authzDecisionQuery: SAML authorsation decision query 325 326 def _createXacmlRequestCtx(self, authzDecisionQuery): 327 """Translate SAML authorisation decision query into a XACML request 328 context 329 """ 330 request = context.request.Request() 331 subject = context.subject.Subject() 332 333 attributeValueFactory = AttributeValueClassFactory() 334 335 openidSubjectAttribute = Attribute() 336 roleAttribute = Attribute() 337 338 openidSubjectAttribute.attributeId = \ 339 authzDecisionQuery.subject.nameID.format 340 341 AnyUriAttributeValue = attributeValueFactory( 342 'http://www.w3.org/2001/XMLSchema#anyURI') 343 344 openidSubjectAttribute.dataType = AnyUriAttributeValue.IDENTIFIER 345 346 openidSubjectAttribute.attributeValues.append(AnyUriAttributeValue()) 347 openidSubjectAttribute.attributeValues[-1].value = \ 348 authzDecisionQuery.subject.nameID.value 349 350 subject.attributes.append(openidSubjectAttribute) 351 352 StringAttributeValue = attributeValueFactory( 353 'http://www.w3.org/2001/XMLSchema#string') 354 355 # TODO: get attributes - replace hard coded values 356 roleAttribute.attributeId = "urn:ndg:security:authz:1.0:attr" 357 roleAttribute.dataType = StringAttributeValue.IDENTIFIER 358 359 roleAttribute.attributeValues.append(StringAttributeValue()) 360 roleAttribute.attributeValues[-1].value = 'staff' 361 362 subject.attributes.append(roleAttribute) 363 364 request.subjects.append(subject) 365 366 resource = Resource() 367 resourceAttribute = Attribute() 368 resource.attributes.append(resourceAttribute) 369 370 resourceAttribute.attributeId = \ 371 "urn:oasis:names:tc:xacml:1.0:resource:resource-id" 372 373 resourceAttribute.dataType = AnyUriAttributeValue.IDENTIFIER 374 resourceAttribute.attributeValues.append(AnyUriAttributeValue()) 375 resourceAttribute.attributeValues[-1].value = \ 376 authzDecisionQuery.resource 377 378 request.resources.append(resource) 379 380 request.action = context.action.Action() 381 actionAttribute = Attribute() 382 request.action.attributes.append(actionAttribute) 383 384 actionAttribute.attributeId = \ 385 "urn:oasis:names:tc:xacml:1.0:action:action-id" 386 actionAttribute.dataType = StringAttributeValue.IDENTIFIER 387 actionAttribute.attributeValues.append(StringAttributeValue()) 388 actionAttribute.attributeValues[-1].value = authzDecisionQuery.actions[0 389 ].value 390 391 return request 392 393 def _createSAMLResponseAssertion(self, authzDecisionQuery, response): 394 """Helper method to add an assertion containing an Authorisation 395 Decision Statement to the SAML response 396 397 @param authzDecisionQuery: SAML Authorisation Decision Query 389 398 @type authzDecisionQuery: ndg.saml.saml2.core.AuthzDecisionQuery 390 @ return: SAML Authorisation Decision Response391 @ rtype: ndg.saml.saml2.core.Response399 @param response: SAML response 400 @type response: ndg.saml.saml2.core.Response 392 401 """ 393 response = Response()394 402 # response = Response() 403 # 395 404 now = datetime.utcnow() 396 405 response.issueInstant = now 397 398 # Make up a request ID that this response is responding to399 response.inResponseTo = authzDecisionQuery.id400 response.id = str(uuid4())401 response.version = SAMLVersion(SAMLVersion.VERSION_20)402 403 response.issuer = Issuer()404 response.issuer.format = self.issuerFormat405 response.issuer.value = self.issuerName406 407 response.status = Status()408 response.status.statusCode = StatusCode()409 response.status.statusMessage = StatusMessage()410 411 response.status.statusCode.value = StatusCode.SUCCESS_URI412 response.status.statusMessage.value = ("Response created "413 "successfully")406 # 407 # # Make up a request ID that this response is responding to 408 # response.inResponseTo = authzDecisionQuery.id 409 # response.id = str(uuid4()) 410 # response.version = SAMLVersion(SAMLVersion.VERSION_20) 411 # 412 # response.issuer = Issuer() 413 # response.issuer.format = self.issuerFormat 414 # response.issuer.value = self.issuerName 415 # 416 # response.status = Status() 417 # response.status.statusCode = StatusCode() 418 # response.status.statusMessage = StatusMessage() 419 # 420 # response.status.statusCode.value = StatusCode.SUCCESS_URI 421 # response.status.statusMessage.value = ("Response created " 422 # "successfully") 414 423 415 424 assertion = Assertion() … … 432 441 assertion.subject.nameID.value = \ 433 442 authzDecisionQuery.subject.nameID.value 434 435 assertion.issuer = Issuer()436 assertion.issuer.format = self.issuerFormat437 assertion.issuer.value = self.issuerName438 443 439 444 authzDecisionStatement = AuthzDecisionStatement() -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/saml/__init__.py
r6721 r6861 67 67 SAML_VERSION_OPTNAME = 'samlVersion' 68 68 ISSUER_OPTNAME = 'issuer' 69 ISSUER_NAME_OPTNAME = 'issuerName' 70 ISSUER_FORMAT_OPTNAME = 'issuerFormat' 69 71 70 72 CONFIG_FILE_OPTNAMES = ( … … 77 79 DESERIALISE_OPTNAME, 78 80 SAML_VERSION_OPTNAME, 79 ISSUER_OPTNAME 81 ISSUER_NAME_OPTNAME, 82 ISSUER_FORMAT_OPTNAME 80 83 ) 81 84 … … 101 104 self.__verifySAMLVersion = True 102 105 self.__samlVersion = SAMLVersion.VERSION_20 103 106 107 # Proxy object for SAML Response Issuer attributes. By generating a 108 # proxy the Response objects inherent attribute validation can be 109 # applied to Issuer related config parameters before they're assigned to 110 # the response issuer object generated in the authorisation decision 111 # query response 112 self.__issuerProxy = Issuer() 113 104 114 def initialise(self, global_conf, prefix='', **app_conf): 105 115 ''' … … 175 185 fset=_setIssuer, 176 186 doc="Name of issuing authority") 187 188 def _getIssuerFormat(self): 189 if self.__issuerProxy is None: 190 return None 191 else: 192 return self.__issuerProxy.value 193 194 def _setIssuerFormat(self, value): 195 if self.__issuerProxy is None: 196 self.__issuerProxy = Issuer() 197 198 self.__issuerProxy.format = value 199 200 issuerFormat = property(_getIssuerFormat, _setIssuerFormat, 201 doc="Issuer format") 202 203 def _getIssuerName(self): 204 if self.__issuerProxy is None: 205 return None 206 else: 207 return self.__issuerProxy.value 208 209 def _setIssuerName(self, value): 210 self.__issuerProxy.value = value 211 212 issuerName = property(_getIssuerName, _setIssuerName, 213 doc="Name of issuer of SAML Query Response") 177 214 178 215 def _getVerifyTimeConditions(self): … … 454 491 samlResponse.issuer = Issuer() 455 492 456 # Nb. SAML 2.0 spec says issuer format must be omitted 457 if self.issuer is not None: 458 samlResponse.issuer.value = self.issuer 493 if self.issuerName is not None: 494 samlResponse.issuer.value = self.issuerName 495 496 if self.issuerFormat is not None: 497 # TODO: Check SAML 2.0 spec says issuer format must be omitted?? 498 samlResponse.issuer.format = self.issuerFormat 459 499 460 500 # Initialise to success status but reset on error -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/ssl.py
r6826 r6861 326 326 def isValidClientCert(self): 327 327 sslClientCert = self.environ[self.sslClientCertKeyName] 328 328 329 329 # Certificate string passed through a proxy has spaces in place of 330 330 # newline delimiters. Fix by re-organising the string into a single … … 361 361 362 362 # Verify against list of acceptable DNs if set 363 363 364 if len(self.clientCertDNMatchList) > 0: 364 365 dn = self.__clientCert.dn … … 372 373 self.clientCertDNMatchList) 373 374 return True 374 else:375 375 376 log.debug("No match found for Client Certificate DN %s in " 376 377 "permitted DNs list %r", dn, self.clientCertDNMatchList) … … 379 380 380 381 self.environ[ 381 ApacheSSLAuthnMiddleware.AUTHN_SUCCEEDED_ENVIRON_KEYNAME] = True 382 ApacheSSLAuthnMiddleware.AUTHN_SUCCEEDED_ENVIRON_KEYNAME] = True 382 383 return True 383 384 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/integration/authz_lite/securityservicesapp.py
r6276 r6861 24 24 os.environ[BaseTestCase.configDirEnvVarName] = TEST_CONFIG_DIR 25 25 26 import optparse 27 26 28 # To start run 27 # $ paster serve services.ini or run this file as a script 28 # $ ./securityservicesapp.py [port #] 29 if __name__ == '__main__': 30 import sys 31 if len(sys.argv) > 1: 32 port = int(sys.argv[1]) 33 else: 34 port = 7443 35 29 # $ paster serve services.ini or run this file as a script, see 30 # $ ./securityservicesapp.py -h 31 if __name__ == '__main__': 32 cfgFileName = INI_FILEPATH 33 cfgFilePath = os.path.join(dirname(abspath(__file__)), cfgFileName) 34 35 parser = optparse.OptionParser() 36 parser.add_option("-p", 37 "--port", 38 dest="port", 39 default=7443, 40 type='int', 41 help="port number to run under") 42 43 parser.add_option("-s", 44 "--with-ssl", 45 dest="withSSL", 46 default='True', 47 help="Run with SSL") 48 49 parser.add_option("-c", 50 "--conf", 51 dest="configFilePath", 52 default=cfgFilePath, 53 help="Configuration file path") 54 36 55 # Initialise test user database 37 56 from ndg.security.test.unit import BaseTestCase 38 57 BaseTestCase.initDb() 39 58 40 cfgFileName = INI_FILEPATH 41 cfgFilePath = os.path.join(dirname(abspath(__file__)), cfgFileName) 59 opt = parser.parse_args()[0] 42 60 43 certFilePath = os.path.join(BaseTestCase.NDGSEC_TEST_CONFIG_DIR, 44 'pki', 45 'localhost.crt') 46 priKeyFilePath = os.path.join(BaseTestCase.NDGSEC_TEST_CONFIG_DIR, 47 'pki', 48 'localhost.key') 61 if opt.withSSL.lower() == 'true': 62 certFilePath = os.path.join(BaseTestCase.NDGSEC_TEST_CONFIG_DIR, 63 'pki', 64 'localhost.crt') 65 priKeyFilePath = os.path.join(BaseTestCase.NDGSEC_TEST_CONFIG_DIR, 66 'pki', 67 'localhost.key') 68 69 ssl_context = SSL.Context(SSL.SSLv23_METHOD) 70 ssl_context.set_options(SSL.OP_NO_SSLv2) 49 71 50 ssl_context = SSL.Context(SSL.SSLv23_METHOD) 51 ssl_context.set_options(SSL.OP_NO_SSLv2) 72 ssl_context.use_privatekey_file(priKeyFilePath) 73 ssl_context.use_certificate_file(certFilePath) 74 else: 75 ssl_context = None 52 76 53 ssl_context.use_privatekey_file(priKeyFilePath) 54 ssl_context.use_certificate_file(certFilePath) 55 56 server = PasteDeployAppServer(cfgFilePath=cfgFilePath, 57 port=port, 77 server = PasteDeployAppServer(cfgFilePath=opt.configFilePath, 78 port=opt.port, 58 79 ssl_context=ssl_context) 59 80 server.start() -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/authz-decision-interface.ini
r6615 r6861 30 30 saml.deserialise = ndg.saml.xml.etree:AuthzDecisionQueryElementTree.fromXML 31 31 saml.serialise = ndg.saml.xml.etree:ResponseElementTree.toXML 32 saml.issuerName = /O=Test/OU=Authorisation Service 33 saml.issuerFormat = urn:oasis:names:tc:SAML:1.1:nameid-format:x509SubjectName 32 34 33 35 #______________________________________________________________________________ … … 39 41 paste.filter_app_factory = ndg.security.test.unit.wsgi.saml.test_soapauthzdecisioninterface:TestAuthorisationServiceMiddleware 40 42 queryInterfaceKeyName = AUTHZ_DECISION_QUERY_FUNC 43 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/authz-service.ini
r6617 r6861 15 15 16 16 [pipeline:main] 17 pipeline = TestAuthorisationServiceFilter SAMLSoapAuthzDecisionInterfaceFilter TestApp17 pipeline = AuthorisationServiceFilter SAMLSoapAuthzDecisionInterfaceFilter TestApp 18 18 19 19 [app:TestApp] … … 28 28 saml.serialise = ndg.saml.xml.etree:ResponseElementTree.toXML 29 29 30 # AuthzDecisionQuery Response settings 31 saml.issuerName = /O=NDG/OU=CEDA/CN=Authorisation Service 32 saml.issuerFormat = urn:oasis:names:tc:SAML:1.1:nameid-format:x509SubjectName 33 saml.clockSkewTolerance = 1 34 saml.assertionLifetime = 86400 35 30 36 #______________________________________________________________________________ 31 37 # Authorisation Service WSGI settings 32 38 # 33 [filter: TestAuthorisationServiceFilter]39 [filter:AuthorisationServiceFilter] 34 40 # This filter is a container for a binding to a SOAP based interface to the 35 41 # Attribute Authority 36 42 paste.filter_app_factory = ndg.security.server.wsgi.authzservice:AuthzServiceMiddleware.filter_app_factory 37 43 prefix = authz. 38 authz.policy .filePath = %(here)s/policy-1.1.xml44 authz.policyFilePath = %(here)s/policy.xml 39 45 authz.queryInterfaceKeyName = %(queryInterfaceKeyName)s 40 41 # AuthzDecisionQuery Response settings42 authz.issuerName = /O=NDG/OU=CEDA/CN=Authorisation Service43 authz.clockSkewTolerance = 144 authz.assertionLifetime = 8640045 46 46 47 # Policy Information Point settings - makes an Attribute Queries to -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/test_soapauthzdecisioninterface.py
r6617 r6861 30 30 QUERY_INTERFACE_KEYNAME_OPTNAME = 'queryInterfaceKeyName' 31 31 RESOURCE_URI = 'http://localhost/dap/data/' 32 ISSUER_DN = '/O= Site A/CN=PDP'32 ISSUER_DN = '/O=Test/OU=Authorisation/CN=Service Stub' 33 33 34 34 def __init__(self, app, global_conf, **app_conf): … … 42 42 43 43 def authzDecisionQueryFactory(self): 44 def authzDecisionQuery(query): 45 response = Response() 44 def authzDecisionQuery(query, response): 46 45 now = datetime.utcnow() 47 46 response.issueInstant = now … … 51 50 response.id = str(uuid4()) 52 51 response.version = SAMLVersion(SAMLVersion.VERSION_20) 53 54 response.issuer = Issuer()55 response.issuer.format = Issuer.X509_SUBJECT56 response.issuer.value = TestAuthorisationServiceMiddleware.ISSUER_DN57 52 58 53 response.status = Status() … … 106 101 issuer="/O=Site A/CN=PEP", 107 102 subject="https://openid.localhost/philip.kershaw", 108 resource= RESOURCE_URI,103 resource=None, 109 104 action=Action.HTTP_GET_ACTION, 110 105 actionNs=Action.GHPP_NS_URI): … … 122 117 query.subject.nameID.format = EsgSamlNamespaces.NAMEID_FORMAT 123 118 query.subject.nameID.value = subject 124 125 query.resource = resource 119 120 if resource is None: 121 query.resource = self.__class__.RESOURCE_URI 122 else: 123 query.resource = resource 124 126 125 query.actions.append(Action()) 127 126 query.actions[0].namespace = actionNs … … 197 196 """ 198 197 CONFIG_FILENAME = 'authz-service.ini' 199 RESOURCE_URI = 'http://localhost/dap/data/my.nc.dods?time[0:1:0]' 200 ACCESS_DENIED_RESOURCE_URI = 'http://localhost/dap/data/test_accessDeniedToSecuredURI' 198 RESOURCE_URI = 'http://localhost/dap/data/my.nc.dods?time[0:1:0]&lat' 199 ACCESS_DENIED_RESOURCE_URI = \ 200 'http://localhost/dap/data/test_accessDeniedToSecuredURI' 201 201 202 202 def __init__(self, *arg, **kw): -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/x509/test_x509.py
r5953 r6861 41 41 42 42 class X509TestCase(BaseTestCase): 43 """Unit test X509 module""" 44 CA_DIR = os.path.join(BaseTestCase.NDGSEC_TEST_CONFIG_DIR, 'ca') 43 45 44 46 def __del__(self): … … 197 199 "isValidTime: %s" % _warningMsg) 198 200 199 201 def test10ReadStackFromCADir(self): 202 203 stack = X509Stack.fromCADir(X509TestCase.CA_DIR) 204 self.assert_(stack) 205 self.assert_(len(stack) > 0) 206 200 207 class X500DNTestCase(BaseTestCase): 201 208 def test01VerifyParsingForFieldsContainingSlash(self):
Note: See TracChangeset
for help on using the changeset viewer.