Changeset 4890
- Timestamp:
- 30/01/09 13:46:56 (12 years ago)
- Location:
- TI12-security/trunk/python
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/controllers/login.py
r4840 r4890 1 1 """Single Sign On Service Login Controller 2 2 3 NERC Data 3 NERC DataGrid Project 4 4 """ 5 5 __author__ = "P J Kershaw" -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/controllers/logout.py
r4384 r4890 1 """Single Sign On Service Logout Controller 2 3 NERC DataGrid Project 4 """ 5 __author__ = "P J Kershaw" 6 __date__ = "10/12/08" 7 __copyright__ = "(C) 2009 Science and Technology Facilities Council" 8 __license__ = "BSD - see LICENSE file in top-level directory" 9 __contact__ = "Philip.Kershaw@stfc.ac.uk" 10 __revision__ = '$Id$' 1 11 from ndg.security.server.sso.sso.lib.base import * 2 12 from ndg.security.common.pylons.security_util import SecuritySession … … 8 18 from urlparse import urlsplit, urlunsplit 9 19 10 from ndg.security.common.sessionmanager import SessionManagerClient 20 from ndg.security.server.wsgi.utils.sessionmanagerclient import \ 21 WSGISessionManagerClient, SessionExpired, AttributeRequestDenied 11 22 12 23 … … 31 42 32 43 try: 33 smClnt = SessionManagerClient(uri=session['ndgSec']['h'], 34 tracefile=cfg.tracefile, 35 **cfg.wss) 44 smClnt = WSGISessionManagerClient(uri=session['ndgSec']['h'], 45 environ=request.environ, 46 tracefile=cfg.tracefile, 47 sslCACertFilePathList=self.cfg.sslCACertFilePathList, 48 **cfg.wss) 36 49 except Exception, e: 37 50 log.error("logout - creating Session Manager client: %s" % e) … … 39 52 40 53 # Disconnect from Session Manager 41 log.info('Calling Session Manager "%s" disconnect for logout...' % \54 log.info('Calling Session Manager "%s" disconnect for logout...' % 42 55 session['ndgSec']['h']) 43 56 try: … … 84 97 getCredentialsIdx = b64decReturnTo.rfind('/getCredentials') 85 98 if getCredentialsIdx != -1: 86 log.debug( \87 "Reverting request URL from getCredentials tologin...")99 log.debug("Reverting request URL from getCredentials to " 100 "login...") 88 101 b64decReturnTo = b64decReturnTo[:getCredentialsIdx] + '/login' 89 102 … … 98 111 99 112 # and now go back to whence we had come 100 log.debug("LogoutController._redirect: redirect to %s" % \113 log.debug("LogoutController._redirect: redirect to %s" % 101 114 b64decReturnTo) 102 115 h.redirect_to(b64decReturnTo) -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/soap.py
r4855 r4890 75 75 # Remove equivalent keyword if present 76 76 kw.pop('referencedFilters', None) 77 78 # The endpoint that this services will be referenced from externally. 79 # e.g. the Session Manager client running locally can check the 80 # input URI and compare with this value to see if the request is 81 # actually to the local Session Manager instance 82 if 'publishedURI' in self.app_conf: 83 self.publishedURI = self.app_conf.pop('publishedURI') 77 84 78 85 -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/utils/attributeauthorityclient.py
r4855 r4890 10 10 __copyright__ = "(C) 2009 Science and Technology Facilities Council" 11 11 __contact__ = "Philip.Kershaw@stfc.ac.uk" 12 __license__ = "BSD - see LICENSE file in top-level directory" 12 13 __revision__ = "$Id$" 13 14 import logging … … 23 24 """Configuration error""" 24 25 25 class WSGIAttributeAuthorityClient( object):26 class WSGIAttributeAuthorityClient(WSGIClientBase): 26 27 """Client interface to Attribute Authority for WSGI based applications 27 28 … … 33 34 environKey = "ndg.security.server.wsgi.attributeAuthorityFilter" 34 35 35 _refInEnviron=lambda self: self._environKey in self._environ36 37 # Define as property for convenient call syntax38 refInEnviron = property(fget=_refInEnviron,39 doc="return True if a Attribute Authority "40 "instance is available in WSGI environ")41 42 36 _getRef = lambda self:self._environ[self._environKey].serviceSOAPBinding.aa 43 37 ref = property(fget=_getRef, doc="Attribute Authority local instance") 44 38 45 46 def __init__(self, environKey=None, environ={}, **soapClientKw): 39 def __init__(self, environKey=None, environ={}, **clientKw): 47 40 48 41 log.debug("WSGIAttributeAuthorityClient.__init__ ...") … … 54 47 55 48 if soapClientKw.get('uri'): 56 self._ soapClient = AttributeAuthorityClient(**soapClientKw)49 self._client = AttributeAuthorityClient(**clientKw) 57 50 else: 58 self._soapClient = None 59 60 def _setEnviron(self, environ): 61 if not isinstance(environ, dict): 62 raise TypeError("Expecting dict type for 'environ' property") 63 self._environ = environ 64 65 def _getEnviron(self, environ): 66 return self._environ 67 68 environ = property(fget=_getEnviron, 69 fset=_setEnviron, 70 doc="WSGI environ dictionary") 51 self._client = None 71 52 72 53 def getHostInfo(self): … … 82 63 return self.ref.hostInfo 83 64 84 elif self._ soapClient is None:65 elif self._client is None: 85 66 raise WSGIAttributeAuthorityClientConfigError("No reference to a " 86 67 "local Attribute Authority is set and no SOAP client " 87 "to a remote service has been initiali zed")68 "to a remote service has been initialised") 88 69 else: 89 70 # Make connection to remote service 90 return self._ soapClient.getHostInfo()71 return self._client.getHostInfo() 91 72 92 73 … … 107 88 # Connect to local instance 108 89 return self.ref.getTrustedHostInfo(**kw) 109 elif self._ soapClient is None:90 elif self._client is None: 110 91 raise WSGIAttributeAuthorityClientConfigError("No reference to a " 111 92 "local Attribute Authority is set and no SOAP client " 112 "to a remote service has been initiali zed")93 "to a remote service has been initialised") 113 94 else: 114 95 # Make connection to remote service 115 return self._ soapClient.getTrustedHostHostInfo(**kw)96 return self._client.getTrustedHostHostInfo(**kw) 116 97 117 98 … … 130 111 allHostsInfo.update(self.ref.getTrustedHostInfo()) 131 112 return allHostsInfo 132 elif self._ soapClient is None:113 elif self._client is None: 133 114 raise WSGIAttributeAuthorityClientConfigError("No reference to a " 134 115 "local Attribute Authority is set and no SOAP client " 135 "to a remote service has been initiali zed")116 "to a remote service has been initialised") 136 117 else: 137 118 # Make connection to remote service 138 return self._ soapClient.getAllHostsInfo()119 return self._client.getAllHostsInfo() 139 120 140 121 … … 160 141 161 142 return self.ref.getAttCert(**kw) 162 elif self._ soapClient is None:143 elif self._client is None: 163 144 raise WSGIAttributeAuthorityClientConfigError("No reference to a " 164 145 "local Attribute Authority is set and no SOAP client " 165 "to a remote service has been initiali zed")146 "to a remote service has been initialised") 166 147 else: 167 148 # Make connection to remote service … … 169 150 kw['userX509Cert'] = kw.pop('holderX509Cert') 170 151 171 return self._ soapClient.getAttCert(**kw)152 return self._client.getAttCert(**kw) -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/utils/sessionmanagerclient.py
r4855 r4890 3 3 Client interface to Session Manager for WSGI based applications 4 4 5 NERC Data Grid Project 6 5 NERC DataGrid Project 7 6 """ 8 7 __author__ = "P J Kershaw" 9 8 __date__ = "27/11/08" 10 9 __copyright__ = "(C) 2009 Science and Technology Facilities Council" 10 __license__ = "BSD - see LICENSE file in top-level directory" 11 11 __contact__ = "Philip.Kershaw@stfc.ac.uk" 12 12 __revision__ = "$Id$" 13 14 13 import logging 15 14 log = logging.getLogger(__name__) … … 18 17 import os 19 18 19 from ndg.security.server.wsgi.utils.clientbase import WSGIClientBase 20 20 from ndg.security.server.wsgi.utils.attributeauthorityclient import \ 21 21 WSGIAttributeAuthorityClient … … 88 88 """Configuration error for WSGI Session Manager Client""" 89 89 90 class WSGISessionManagerClient( object):90 class WSGISessionManagerClient(WSGIClientBase): 91 91 """Client interface to Session Manager for WSGI based applications 92 92 … … 108 108 environKey = "ndg.security.server.wsgi.sessionManagerFilter" 109 109 attributeAuthorityEnvironKey = WSGIAttributeAuthorityClient.environKey 110 111 _refInEnviron = lambda self: self._environKey in self._environ 112 113 # Define as property for convenient call syntax 114 refInEnviron = property(fget=_refInEnviron, 115 doc="return True if a Session Manager instance is " 116 "available in WSGI environ") 117 110 118 111 _getRef = lambda self:self._environ[self._environKey].serviceSOAPBinding.sm 119 ref = property(fget=_getRef, doc=" Session Manager localinstance")112 ref = property(fget=_getRef, doc="local session manager instance") 120 113 121 114 … … 136 129 137 130 if soapClientKw.get('uri'): 138 self._soapClient = SessionManagerClient(**soapClientKw) 139 else: 140 self._soapClient = None 141 142 def _setEnviron(self, environ): 143 if not isinstance(environ, dict): 144 raise TypeError("Expecting dict type for 'environ' property") 145 self._environ = environ 146 147 def _getEnviron(self, environ): 148 return self._environ 149 150 environ = property(fget=_getEnviron, 151 fset=_setEnviron, 152 doc="WSGI environ dictionary") 153 131 self._client = SessionManagerClient(**soapClientKw) 132 else: 133 self._client = None 134 135 154 136 def connect(self, username, **kw): 155 137 """Request a new user session from the Session Manager … … 168 150 res = self.ref.connect(username=username, **kw) 169 151 170 elif self._ soapClient is None:152 elif self._client is None: 171 153 raise WSGISessionManagerClientConfigError("No reference to a " 172 154 "local Session Manager is set and no SOAP client " … … 180 162 181 163 # Make connection to remote service 182 res = self._ soapClient.connect(username, **kw)164 res = self._client.connect(username, **kw) 183 165 184 166 # Convert from unicode because unicode causes problems with … … 209 191 self.ref.deleteUserSession(**kw) 210 192 211 elif self._ soapClient is None:193 elif self._client is None: 212 194 raise WSGISessionManagerClientConfigError("No reference to a " 213 195 "local Session Manager is set and no SOAP client " … … 217 199 kw['userDN'] = kw.pop('userX509Cert').dn 218 200 219 self._ soapClient.disconnect(**kw)201 self._client.disconnect(**kw) 220 202 221 203 … … 233 215 return self.ref.getSessionStatus(**kw) 234 216 235 elif self._ soapClient is None:236 raise WSGISessionManagerClientConfigError("No reference to a " 237 "local Session Manager is set and no SOAP client " 238 "to a remote service has been initialized") 239 else: 240 return self._ soapClient.getSessionStatus(**kw)217 elif self._client is None: 218 raise WSGISessionManagerClientConfigError("No reference to a " 219 "local Session Manager is set and no SOAP client " 220 "to a remote service has been initialized") 221 else: 222 return self._client.getSessionStatus(**kw) 241 223 242 224 … … 272 254 return self.ref.getAttCert(**kw) 273 255 274 elif self._ soapClient is None:256 elif self._client is None: 275 257 raise WSGISessionManagerClientConfigError("No reference to a " 276 258 "local Session Manager is set and no SOAP client " … … 303 285 'this keyword') 304 286 305 return self._ soapClient.getAttCert(**kw)287 return self._client.getAttCert(**kw) -
TI12-security/trunk/python/ndg.security.server/setup.py
r4884 r4890 90 90 'ndg.security.server.sso': ['*.ini', '*.cfg', '*.txt'], 91 91 'ndg.security.server.sso.sso': ['public/*.*', 'public/layout/*.*'], 92 'ndg.security.server.sso.sso.badc_site': ['public/*.*', 'public/layout/*.*'], 92 'ndg.security.server.sso.sso.badc_site': [ 93 'public/*.*', 94 'public/layout/*.*', 95 'public/layout/logos/*.*', 96 'public/layout/styles/*.*', 97 'public/layout/tabs/*.*' 98 ], 93 99 'ndg.security.server.sso.sso.templates.ndg.security': ['*.kid'], 94 100 'ndg.security.server.sso.sso.badc_site.templates.ndg.security': ['*.kid'], -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/combinedservices/services.ini
r4873 r4890 140 140 use = egg:Paste#http 141 141 host = 0.0.0.0 142 port = 5000142 port = 8000 143 143 144 144 [filter-app:mainApp] … … 242 242 path = /AttributeAuthority 243 243 244 # External endpoint for this Attribute Authority - must agree with setting used 245 # to invoke this service set in: 246 # * serverapp.py 247 # * or port in [server:main] if calling with paster serve services.ini 248 # * or something else e.g. proxied through Apache? 249 # This setting is used by Attribute Authority clients in this WSGI stack to see 250 # if a request is being made to the local service or to another Attribute 251 # Authority running elsewhere 252 publishedURI = http://localhost:8000%(path)s 253 244 254 # Enable ?wsdl query argument to list the WSDL content 245 255 enableWSDLQuery = True … … 279 289 filter:AttributeAuthorityFilter 280 290 281 # Path from UR Lfor Session Manager in this Paste deployment291 # Path from URI for Session Manager in this Paste deployment 282 292 path = /SessionManager 293 294 # External endpoint for this Session Manager - must agree with setting used to 295 # invoke this service set in: 296 # * serverapp.py 297 # * or port in [server:main] if calling with paster serve services.ini 298 # * or something else e.g. proxied through Apache? 299 # This setting is used by Session Manager clients in this WSGI stack to see if 300 # a request is being made to the local service or to another session manager 301 # running elsewhere 302 publishedURI = http://localhost:8000%(path)s 283 303 284 304 # Enable ?wsdl query argument to list the WSDL content -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/combinedservices/singlesignonservice/sso.cfg
r4883 r4890 15 15 # Switch to alternative location to pick up public/ dir containing static 16 16 # content such as graphics and stylesheets 17 #configDir= /home/pjkersha/workspace/security/python/ndg.security.server/ndg/security/server/sso/sso/badc_site17 #configDir=%(here)s 18 18 19 19 # Switch from default templates package to templates/ in alternative directory
Note: See TracChangeset
for help on using the changeset viewer.