Changeset 6604 for TI12-security/trunk/NDGSecurity
- Timestamp:
- 22/02/10 14:14:34 (11 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/.pydevproject
r6570 r6604 6 6 <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> 7 7 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> 8 <path>/ndg_security_python</path> 8 <path>/ndg_security_python/ndg_security_client</path> 9 <path>/ndg_security_python/ndg_security_common</path> 10 <path>/ndg_security_python/ndg_security_server</path> 11 <path>/ndg_security_python/ndg_security_test</path> 9 12 </pydev_pathproperty> 10 13 <pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH"> -
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/__init__.py
r6597 r6604 28 28 def __setitem__(self, key, val): 29 29 if key not in self.__class__.namespaces: 30 raise KeyError('Namespace "%s"not recognised. Valid namespaces '31 'are: % s' % self.__class__.namespaces)30 raise KeyError('Namespace %r not recognised. Valid namespaces ' 31 'are: %r' % (key, self.__class__.namespaces)) 32 32 33 33 dict.__setitem__(self, key, val) … … 50 50 51 51 52 class SubjectBase( object):52 class SubjectBase(_AttrDict): 53 53 '''Base class Subject designator''' 54 namespaces = ("urn:ndg:security:authz:1.0:attr:subject:roles", ) 55 (ROLES_NS,) = namespaces 54 namespaces = ( 55 "urn:ndg:security:authz:1.0:attr:subject:userId", 56 "urn:ndg:security:authz:1.0:attr:subject:roles", 57 ) 58 (USERID_NS, ROLES_NS,) = namespaces 59 60 61 class Subject(SubjectBase): 62 """Container for information about the subject of the query""" -
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/msi.py
r6597 r6604 20 20 from ndg.security.common.utils import TypedList 21 21 from ndg.security.common.utils.etree import QName 22 from ndg.security.common.authz import _AttrDict, SubjectBase 22 from ndg.security.common.authz import (_AttrDict, SubjectBase, Subject, 23 SubjectRetrievalError) 23 24 from ndg.security.common.authz.pip import (PIPBase, PIPAttributeQuery, 24 PIPAttributeResponse, 25 SubjectRetrievalError) 25 PIPAttributeResponse) 26 26 27 27 … … 346 346 347 347 348 class Subject(SubjectBase):349 '''MSI Subject designator'''350 351 352 348 class Resource(_AttrDict): 353 349 '''Resource designator''' … … 360 356 class Request(object): 361 357 '''Request to send to a PDP''' 358 # __slots__ = ('__subject', '__resource') 359 362 360 def __init__(self, subject=Subject(), resource=Resource()): 363 361 self.subject = subject … … 368 366 369 367 def _setSubject(self, subject): 370 if not isinstance(subject, Subject ,):371 raise TypeError("Expecting % stype for Request subject; got %r" %372 (Subject .__class__.__name__, subject))368 if not isinstance(subject, SubjectBase): 369 raise TypeError("Expecting %r type for Request subject; got %r" % 370 (Subject, type(subject))) 373 371 self.__subject = subject 374 372 … … 390 388 fset=_setResource, 391 389 doc="Resource to be protected") 392 390 # 391 # def __getstate__(self): 392 # '''Enable pickling''' 393 # _dict = {} 394 # for attrName in Request.__slots__: 395 # # Ugly hack to allow for derived classes setting private member 396 # # variables 397 # if attrName.startswith('__'): 398 # attrName = "_Request" + attrName 399 # 400 # _dict[attrName] = getattr(self, attrName) 401 # 402 # return _dict 403 # 404 # def __setstate__(self, attrDict): 405 # '''Enable pickling''' 406 # for attrName, val in attrDict.items(): 407 # setattr(self, attrName, val) 408 393 409 394 410 class Response(object): -
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/pip/__init__.py
r6597 r6604 12 12 __contact__ = "Philip.Kershaw@stfc.ac.uk" 13 13 __revision__ = "$Id: __init__.py 3755 2008-04-04 09:11:44Z pjkersha $" 14 from ndg.security.common.authz import _AttrDict 14 from ndg.security.common.authz import _AttrDict, Subject 15 15 16 16 -
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/pip/ndginterface.py
r6598 r6604 34 34 35 35 from ndg.security.common.authz import SubjectBase, SubjectRetrievalError 36 from ndg.security.common.authz.pip import (PIPAttributeQuery, 37 PIPAttributeResponse) 38 from ndg.security.common.authz.pdp import PDPUserAccessDenied 36 from ndg.security.common.authz.pip import (PIPAttributeQuery, PIPBase, 37 PIPAttributeResponse) 39 38 40 39 … … 110 109 AttributeCertificateRequestError.__doc__) 111 110 112 111 class AttributeCertificateRequestDenied(SubjectRetrievalError): 112 'The request for a certificate containing authorisation roles was denied' 113 def __init__(self, msg=None): 114 SubjectRetrievalError.__init__(self, msg or 115 AttributeCertificateRequestError.__doc__) 116 117 113 118 class PIP(PIPBase): 114 119 """Policy Information Point - this implementation enables the PDP to … … 261 266 except AttributeRequestDenied, e: 262 267 log.error("Request for attribute certificate denied: %s" % e) 263 raise PDPUserAccessDenied()268 raise AttributeCertificateRequestDenied() 264 269 265 270 except SessionNotFound, e: … … 326 331 log.error("Request for attribute certificate denied: %s", 327 332 traceback.format_exc()) 328 raise PDPUserAccessDenied()333 raise AttributeCertificateRequestDenied() 329 334 330 335 # TODO: handle other specific Exception types here for more fine -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/authz/__init__.py
r6597 r6604 39 39 from ndg.security.server.wsgi.authz.result_handler.basic import \ 40 40 PEPResultHandlerMiddleware 41 42 from ndg.security.common.authz.msi import (Policy, PIP, PIPBase, 43 PIPAttributeQuery, 44 PIPAttributeResponse, PDP, Request, 45 Response, Resource, Subject) 41 42 from ndg.security.common.authz.pip import (PIPBase, PIPAttributeQuery, 43 PIPAttributeResponse) 44 45 # The NDG Interface Subject type includes support for Session Manager related 46 # keywords which are not needed by the newer SamlPIPMiddleware 47 from ndg.security.common.authz.pip.ndginterface import PIP, Subject 48 from ndg.security.common.authz.msi import (Policy, PDP, Request, 49 Response, Resource) 46 50 47 51 … … 150 154 "user authorisation ...") 151 155 152 # Make a request object to pass to the PDP 153 request = Request() 156 # Make a request object to pass to the PDP. Set an NDG type Subject 157 # which has the extra keyword support for Session Manager and 158 # Session ID needed by NdgPIPMiddleware. This can be deprecated in a 159 # future release when the SOAP/WSL attribute interface is withdrawn 160 # and completely replaced by the SAML one 161 request = Request(subject=Subject()) 154 162 request.subject[Subject.USERID_NS] = session['username'] 155 163 -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/authzservice.py
r6597 r6604 13 13 14 14 from ndg.security.common.utils.factory import importModuleObject 15 from ndg.security.common.authz.msi import Policy, PDP 15 from ndg.security.common.authz import Subject 16 from ndg.security.common.authz.msi import (Policy, PDP, Request, Response, 17 Resource) 16 18 from ndg.security.common.authz.pip.esg import PIP 17 19 … … 174 176 self.__authzDecisionFunc = importModuleObject(value) 175 177 176 elif iscallable(value):178 elif callable(value): 177 179 self.__authzDecisionFunc = value 178 180 else: -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/session.py
r6440 r6604 14 14 log = logging.getLogger(__name__) 15 15 16 import urllib 17 from paste.request import parse_querystring 18 16 19 from ndg.security.server.wsgi import (NDGSecurityMiddlewareBase, 17 20 NDGSecurityMiddlewareError) … … 89 92 90 93 AUTH_TKT_SET_USER_ENVIRON_KEYNAME = 'paste.auth_tkt.set_user' 94 95 LOGOUT_RETURN2URI_ARGNAME = 'ndg.security.logout.r' 91 96 92 97 PARAM_PREFIX = 'sessionHandler.' … … 179 184 session.save() 180 185 181 referrer = environ.get('HTTP_REFERER') 186 if self.__class__.LOGOUT_RETURN2URI_ARGNAME in environ['QUERY_STRING']: 187 params = dict(parse_querystring(environ)) 188 189 # Store the return URI query argument in a beaker session 190 quotedReferrer = params.get( 191 self.__class__.LOGOUT_RETURN2URI_ARGNAME, '') 192 referrer = urllib.unquote(quotedReferrer) 193 else: 194 referrer = environ.get('HTTP_REFERER') 195 182 196 if referrer is not None: 183 197 def _start_response(status, header, exc_info=None): … … 191 205 exc_info) 192 206 193 return _start_response 207 return _start_response 194 208 else: 195 209 log.error('No referrer set for redirect following logout') -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/integration/authz_lite/securityservices.ini
r6575 r6604 406 406 # SAML SOAP Binding to the Attribute Authority 407 407 [filter:AttributeAuthoritySamlSoapBindingFilter] 408 paste.filter_app_factory = ndg.security.server.wsgi.saml .attributeinterface:SOAPAttributeInterfaceMiddleware.filter_app_factory408 paste.filter_app_factory = ndg.security.server.wsgi.saml:SOAPQueryInterfaceMiddleware.filter_app_factory 409 409 prefix = saml.soapbinding. 410 411 saml.soapbinding.deserialise = saml.xml.etree:AttributeQueryElementTree.fromXML 412 413 # Specialisation to incorporate ESG Group/Role type 414 saml.soapbinding.serialise = ndg.security.common.saml_utils.esg.xml.etree:EsgResponseElementTree.toXML 410 415 411 416 saml.soapbinding.pathMatchList = /AttributeAuthority/saml
Note: See TracChangeset
for help on using the changeset viewer.