Changeset 3914 for TI12-security/trunk
- Timestamp:
- 20/05/08 17:11:20 (12 years ago)
- Location:
- TI12-security/trunk/python
- Files:
-
- 4 added
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/Tests/authtest/development.ini
r3892 r3914 14 14 use = egg:Paste#http 15 15 host = 0.0.0.0 16 port = 5 00016 port = 5100 17 17 18 18 [app:main] … … 54 54 # This is optional - see: 55 55 # http://wiki.pylonshq.com/display/authkitcookbook/OpenID+Passurl 56 authkit.openid.baseurl = http://localhost:5 00056 authkit.openid.baseurl = http://localhost:5100 57 57 58 58 # Template for signin … … 61 61 # Logging configuration 62 62 [loggers] 63 keys = root, authtest 63 keys = root, authtest, authkit 64 64 65 65 [handlers] … … 78 78 qualname = authtest 79 79 80 [logger_authkit] 81 level = DEBUG 82 handlers = 83 qualname = authkit 84 80 85 [handler_console] 81 86 class = StreamHandler -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/AttAuthority/AttAuthority_services.py
r3832 r3914 8 8 import urlparse, types 9 9 from ZSI.TCcompound import ComplexType, Struct 10 from ndg.security.common.zsi_utils import urllib2client asclient10 from ZSI import client 11 11 import ZSI 12 12 from ZSI.generate.pyclass import pyclass_type … … 29 29 # no ws-addressing 30 30 31 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 a3dec>31 # op: <ZSI.wstools.WSDLTools.Message instance at 0x8460c4c> 32 32 def getAttCert(self, userId,userCert,userAttCert): 33 33 … … 46 46 return attCert,msg 47 47 48 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 a812c>48 # op: <ZSI.wstools.WSDLTools.Message instance at 0x8460f8c> 49 49 def getHostInfo(self): 50 50 … … 64 64 return hostname,aaURI,aaDN,loginURI,loginServerDN,loginRequestServerDN 65 65 66 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 a8d8c>66 # op: <ZSI.wstools.WSDLTools.Message instance at 0x8466bec> 67 67 def getTrustedHostInfo(self, role): 68 68 … … 78 78 return trustedHosts 79 79 80 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 a8f2c>80 # op: <ZSI.wstools.WSDLTools.Message instance at 0x8466d8c> 81 81 def getAllHostsInfo(self): 82 82 … … 91 91 return hosts 92 92 93 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 b20cc>93 # op: <ZSI.wstools.WSDLTools.Message instance at 0x8466f0c> 94 94 def getX509Cert(self): 95 95 -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/AttAuthority/Makefile
r3832 r3914 17 17 OPTS=-be -f 18 18 19 STUB_FILE=AttAuthority_services.py20 TMP_FILE=AttAuthority_services.tmp21 22 ORIG1=from ZSI import client23 REPL1=from ndg.security.common.zsi_utils import urllib2client as client24 25 19 generateStubs: ${WSDL_FILE} 26 20 @echo Generate stub ... 27 21 ${CMD} ${OPTS} ${WSDL_FILE} 28 @echo Make substitutions for HTTP Proxy custom Client Binding class fix ...29 cat ${STUB_FILE}|sed s/"${ORIG1}"/"${REPL1}"/g > ${TMP_FILE}30 @mv ${TMP_FILE} ${STUB_FILE}31 22 @echo Done. 32 23 -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/AttAuthority/__init__.py
r3755 r3914 38 38 HostCheck 39 39 40 from ndg.security.common.zsi_utils.httpproxy import ProxyHTTPConnection 41 40 42 import logging 41 43 log = logging.getLogger(__name__) … … 73 75 uri=None, 74 76 tracefile=None, 77 httpProxyHost=None, 78 ignoreHttpProxyEnv=False, 75 79 sslCACertList=[], 76 80 sslCACertFilePathList=[], … … 111 115 self.__uri = None 112 116 self._transdict = {} 117 self._transport = HTTPProxyConnection 113 118 114 119 if uri: 115 120 self.__setURI(uri) 116 121 122 self.__setHTTPProxyHost(httpProxyHost) 123 self.__setIgnoreHttpProxyEnv(ignoreHttpProxyEnv) 124 117 125 if sslPeerCertCN: 118 126 self.__setSSLPeerCertCN(sslPeerCertCN) … … 157 165 self._transport = HTTPSConnection 158 166 else: 159 self._transport = None167 self._transport = ProxyHTTPConnection 160 168 161 169 … … 168 176 169 177 uri = property(fset=__setURI, fget=__getURI,doc="Attribute Authority URI") 178 179 180 #_________________________________________________________________________ 181 def __setHTTPProxyHost(self, val): 182 """Set a HTTP Proxy host overriding any http_proxy environment variable 183 setting""" 184 if self._transport != ProxyHTTPConnection: 185 raise AttAuthorityClientError(\ 186 "Setting HTTP Proxy Host but transport class is not " + \ 187 "ProxyHTTPConnection type") 188 189 self._transdict['httpProxyHost'] = val 190 191 httpProxyHost = property(fset=__setHTTPProxyHost, 192 doc="HTTP Proxy hostname - overrides any http_proxy env var setting") 193 194 195 #_________________________________________________________________________ 196 def __setIgnoreHttpProxyEnv(self, val): 197 """Set to True to ignore any http_proxy environment variable setting""" 198 if self._transport != ProxyHTTPConnection: 199 raise AttAuthorityClientError(\ 200 "Setting ignore HTTP Proxy Host flag but transport class " + \ 201 "is not ProxyHTTPConnection type") 202 203 self._transdict['ignoreHttpProxyEnv'] = val 204 205 ignoreHttpProxyEnv = property(fset=__setIgnoreHttpProxyEnv, 206 doc="Set to True to ignore any http_proxy environment variable setting") 170 207 171 208 … … 362 399 @return: dictionary of host information indexed by hostname derived 363 400 from the map configuration""" 364 401 402 hosts = self.__srv.getAllHostsInfo() 365 403 try: 366 404 hosts = self.__srv.getAllHostsInfo() -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/SessionMgr/Makefile
r3832 r3914 17 17 OPTS=-be -f 18 18 19 STUB_FILE=SessionMgr_services.py20 TMP_FILE=SessionMgr_services.tmp21 22 ORIG1=from ZSI import client23 REPL1=from ndg.security.common.zsi_utils import urllib2client as client24 25 19 generateStubs: ${WSDL_FILE} 26 20 @echo Generate stub ... 27 21 ${CMD} ${OPTS} ${WSDL_FILE} 28 @echo Make substitutions for HTTP Proxy custom Client Binding class fix ...29 cat ${STUB_FILE}|sed s/"${ORIG1}"/"${REPL1}"/g > ${TMP_FILE}30 @mv ${TMP_FILE} ${STUB_FILE}31 22 @echo Done. 32 23 -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/SessionMgr/SessionMgr_services.py
r3832 r3914 8 8 import urlparse, types 9 9 from ZSI.TCcompound import ComplexType, Struct 10 from ndg.security.common.zsi_utils import urllib2client asclient10 from ZSI import client 11 11 import ZSI 12 12 from ZSI.generate.pyclass import pyclass_type … … 29 29 # no ws-addressing 30 30 31 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 a844c>31 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84652ac> 32 32 def getSessionStatus(self, userDN,sessID): 33 33 … … 44 44 return isAlive 45 45 46 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 a874c>46 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84655ac> 47 47 def connect(self, username,passphrase,createServerSess): 48 48 … … 63 63 return userCert,userPriKey,issuingCert,sessID 64 64 65 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 af46c>65 # op: <ZSI.wstools.WSDLTools.Message instance at 0x846d2cc> 66 66 def disconnect(self, userCert,sessID): 67 67 … … 77 77 return 78 78 79 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 af60c>79 # op: <ZSI.wstools.WSDLTools.Message instance at 0x846d46c> 80 80 def getAttCert(self, userCert,sessID,attAuthorityURI,attAuthorityCert,reqRole,mapFromTrustedHosts,rtnExtAttCertList,extAttCert,extTrustedHost): 81 81 … … 101 101 return attCert,msg,extAttCertOut 102 102 103 # op: <ZSI.wstools.WSDLTools.Message instance at 0x84 af78c>103 # op: <ZSI.wstools.WSDLTools.Message instance at 0x846d5ec> 104 104 def getX509Cert(self): 105 105 -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/SessionMgr/__init__.py
r3790 r3914 28 28 from ndg.security.common.m2CryptoSSLUtility import HTTPSConnection, \ 29 29 HostCheck 30 from ndg.security.common.zsi_utils.httpproxy import ProxyHTTPConnection 30 31 from SessionMgr_services import SessionMgrServiceLocator 31 32 … … 119 120 uri=None, 120 121 tracefile=None, 122 httpProxyHost=None, 123 ignoreHttpProxyEnv=False, 121 124 sslCACertList=[], 122 125 sslCACertFilePathList=[], … … 159 162 self.__uri = None 160 163 self._transdict = {} 161 self._transport = None164 self._transport = ProxyHTTPConnection 162 165 163 166 if uri: 164 167 self.__setURI(uri) 168 169 self.__setHTTPProxyHost(httpProxyHost) 170 self.__setIgnoreHttpProxyEnv(ignoreHttpProxyEnv) 165 171 166 172 if sslPeerCertCN: … … 195 201 196 202 if not isinstance(uri, basestring): 197 raise SessionMgrClientError , \198 "Session Manager WSDL URI must be a valid string" 203 raise SessionMgrClientError( 204 "Session Manager WSDL URI must be a valid string") 199 205 200 206 self.__uri = uri … … 202 208 scheme = urlparse.urlparse(self.__uri)[0] 203 209 except TypeError: 204 raise AttributeAuthorityClientError , \205 "Error parsing transport type from URI"210 raise AttributeAuthorityClientError( 211 "Error parsing transport type from URI") 206 212 207 213 if scheme == "https": 208 214 self._transport = HTTPSConnection 209 215 else: 210 self._transport = None216 self._transport = ProxyHTTPConnection 211 217 212 218 # Ensure SSL settings are cancelled … … 222 228 uri = property(fset=__setURI, fget=__getURI, doc="Session Manager URI") 223 229 230 231 #_________________________________________________________________________ 232 def __setHTTPProxyHost(self, val): 233 """Set a HTTP Proxy host overriding any http_proxy environment variable 234 setting""" 235 if self._transport != ProxyHTTPConnection: 236 raise SessionMgrClientError(\ 237 "Setting HTTP Proxy Host - transport class is %s type, " % \ 238 self._transport + \ 239 "expecting ProxyHTTPConnection type") 240 241 self._transdict['httpProxyHost']= val 242 243 httpProxyHost = property(fset=__setHTTPProxyHost, 244 doc="HTTP Proxy hostname - overrides any http_proxy env var setting") 245 246 247 #_________________________________________________________________________ 248 def __setIgnoreHttpProxyEnv(self, val): 249 """Set to True to ignore any http_proxy environment variable setting""" 250 if self._transport != ProxyHTTPConnection: 251 raise SessionMgrClientError(\ 252 "Setting ignore HTTP Proxy Host flag but transport class " + \ 253 "is not ProxyHTTPConnection type") 254 255 self._transdict['ignoreHttpProxyEnv']= val 256 257 ignoreHttpProxyEnv = property(fset=__setIgnoreHttpProxyEnv, 258 doc="Set to True to ignore any http_proxy environment variable setting") 259 224 260 225 261 #_________________________________________________________________________ -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/development.ini
r3754 r3914 29 29 #beaker.session.data_dir = %(here)s/data/sessions 30 30 31 authkit.setup.method=openid, cookie 32 authkit.cookie.secret=secret encryption string 33 authkit.cookie.signoutpath = /openidsignout 34 authkit.openid.path.signedin=/login 35 authkit.openid.store.type=file 36 authkit.openid.store.config=%(here)s/data/openid 37 #authkit.openid.path.process=/login 38 39 # Copied from http://wiki.pylonshq.com/display/authkitcookbook/OpenID+Passurl 40 #authkit.openid.session.middleware = beaker.session 41 authkit.openid.session.key = authkit_openid 42 authkit.openid.session.secret = random string 43 44 # This is optional - see: 45 # http://wiki.pylonshq.com/display/authkitcookbook/OpenID+Passurl 46 authkit.openid.baseurl = http://localhost/sso 47 48 # Template for signin 49 authkit.openid.template.obj = sso.lib.openid_util:make_template 50 51 # Handler for parsing OpenID and creating a session from it 52 authkit.openid.urltouser = sso.lib.openid_util:url2user 53 31 54 # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* 32 55 # Debug mode will enable the interactive debugging tool, allowing ANYONE to … … 56 79 qualname = sso 57 80 81 [logger_authkit] 82 level = DEBUG 83 handlers = 84 qualname = authkit 58 85 59 86 [logger_ndg] -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso.cfg
r3754 r3914 11 11 disclaimer: 12 12 13 [NDG_SECURITY]14 13 # Redirect SOAP output to a file e.g. open(<somefile>, 'w') 15 14 tracefile: None … … 20 19 attAuthorityURI: http://localhost:5000/AttributeAuthority 21 20 22 # WS-Security signature handler 23 wssCfgFilePath: ./wssecurity.cfg 21 # WS-Security signature handler - set a config file with 'wssCfgFilePath' 22 # or omit and put the relevant content directly in here under 23 # 'NDG_SECURITY.wssecurity' section 24 #wssCfgFilePath: wssecurity.cfg 24 25 25 26 # SSL Connections … … 30 31 sslCACertFilePathList: certs/ndg-test-ca.crt 31 32 32 # Set an alternate CommonName to match with peer cert for SSL 33 # Connections. If the CN=hostname of the peer then this option 34 # can be commented out 35 sslPeerCertCN: 33 # Web Services HTTP Proxy fine tuning 34 # 35 # For most situations, these settings can be ignored and instead make use of 36 # the http_proxy environment variable. They allow for the case where specific 37 # settings are needed just for the security web services calls 36 38 37 # Gatekeeper Attribute Certificate check 38 # Issuer - should match with the issuer element of the users Attribute 39 # Certificate submitted in order to gain access 40 acIssuer: /CN=AttributeAuthority/O=NDG/OU=BADC 41 #acIssuer: /CN=Junk/O=NDG/OU=Gabriel 39 # Overrides the http_proxy environment variable setting - may be omitted 40 #httpProxyHost: wwwcache.rl.ac.uk:8080 42 41 43 # verification of X.509 cert back to CA 44 acCACertFilePathList: certs/ndg-test-ca.crt 42 # Web service clients pick up the http_proxy environment variable setting by 43 # default. Set this flag to True to ignore http_proxy for web service 44 # connections. To use the http_proxy setting, set this parameter to False or 45 # remove it completely from this file. 46 ignoreHttpProxyEnv: True 47 48 49 # Flag to enable OpenID login 50 enableOpenID: True 51 52 [WSSecurity] 53 54 # Settings for signature of an outbound message ... 55 56 # Certificate associated with private key used to sign a message. The sign 57 # method will add this to the BinarySecurityToken element of the WSSE header. 58 # binSecTokValType attribute must be set to 'X509' or 'X509v3' ValueType. 59 # As an alternative, use 'signingCertChain' parameter 60 61 # file path PEM encoded cert 62 signingCertFilePath=certs/clnt.crt 63 64 # file path to PEM encoded private key file 65 signingPriKeyFilePath=certs/clnt.key 66 67 # Password protecting private key. Leave blank if there is no password. 68 signingPriKeyPwd= 69 70 # Provide a space separated list of file paths. CA Certs should be included 71 # for all the sites this installation trusts 72 caCertFilePathList=certs/ndg-test-ca.crt 73 74 # Set the ValueType for the BinarySecurityToken added to the WSSE header for a 75 # signed message. 76 reqBinSecTokValType=X509v3 77 78 # Add a timestamp element to an outbound message 79 addTimestamp=True 80 81 # For WSSE 1.1 - service returns signature confirmation containing signature 82 # value sent by client 83 applySignatureConfirmation=False 84 85 tracefile=sys.stderr 45 86 46 87 [layout] -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/config/environment.py
r3652 r3914 32 32 # CONFIGURATION OPTIONS HERE (note: all config options will override 33 33 # any Pylons config options) 34 35 # Make a dedicated alias for SSO Service templates to avoid possible 36 # conflicts when importing SSO Service code into another pylons project 37 kidopts = {'kid.assume_encoding':'utf-8', 'kid.encoding':'utf-8'} 38 config.add_template_engine('kid', 39 'ndg.security.server.sso.sso.templates', 40 kidopts, 41 alias='ndg.security.kid') -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/config/middleware.py
r3754 r3914 12 12 13 13 from sso.config.environment import load_environment 14 15 14 from sso.config.ssoServiceMiddleware import SSOMiddleware 15 import logging 16 log = logging.getLogger(__name__) 16 17 17 18 def make_app(global_conf, full_stack=True, **app_conf): … … 41 42 # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 42 43 app = SSOMiddleware(app, app_conf['configfile'], app.globals) 43 44 45 # OpenID Middleware 46 if app.globals.ndg.security.server.ssoservice.cfg.enableOpenID: 47 import authkit.authenticate 48 from beaker.middleware import SessionMiddleware 49 50 app = authkit.authenticate.middleware(app, app_conf) 51 app = SessionMiddleware(app)#,key='authkit.open_id',secret='some secret') 52 log.info('OpenID is enabled') 44 53 45 54 if asbool(full_stack): -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/config/ssoServiceMiddleware.py
r3896 r3914 39 39 40 40 appGlobals.ndg = ndg 41 41 self.globals = appGlobals 42 42 43 def __call__(self, environ, start_response): 43 44 … … 85 86 defSection='DEFAULT', 86 87 layoutSection='layout', 87 wssSection=' NDG_SECURITY.wssecurity'):88 wssSection='WSSecurity'): 88 89 '''Extract content of config file object into self''' 89 90 … … 105 106 'No "sslCACertFilePathList" security setting' 106 107 108 109 # HTTP Proxy setting for web service connections... 110 111 # Override an http_proxy env setting 112 if self.cfg.has_option(defSection, 'httpProxyHost'): 113 self.httpProxyHost = self.cfg.get(defSection, 'httpProxyHost') 114 else: 115 self.httpProxyHost = None 116 117 # Set this to True if the http_proxy environment variable should be 118 # ignored in this case 119 if self.cfg.has_option(defSection, 'ignoreHttpProxyEnv'): 120 self.ignoreHttpProxyEnv = self.cfg.getboolean(defSection, 121 'ignoreHttpProxyEnv') 122 else: 123 self.ignoreHttpProxyEnv = False 124 125 107 126 # If no separate WS-Security config file is set then read these params 108 127 # from the current config file … … 136 155 self.wayfuri='%s/wayf' % self.server 137 156 157 # Flag to enable OpenID interface 158 try: 159 self.enableOpenID = self.cfg.getboolean(defSection, 'enableOpenID') 160 except ConfigParser.NoOptionError: 161 self.enableOpenID = False 162 138 163 self.localLink=self.cfg.get(layoutSection, 'localLink', None) 139 164 self.localImage=self.cfg.get(layoutSection, 'localImage', None) 140 self.localAlt=self.cfg.get(layoutSection, 'localAlt', 'Visit Local Site') 141 self.ndgLink=self.cfg.get(layoutSection, 'ndgLink', 'http://ndg.nerc.ac.uk') 165 self.localAlt=self.cfg.get(layoutSection, 'localAlt', 166 'Visit Local Site') 167 self.ndgLink=self.cfg.get(layoutSection, 'ndgLink', 168 'http://ndg.nerc.ac.uk') 142 169 self.ndgImage=self.cfg.get(layoutSection, 'ndgImage', None) 143 170 self.ndgAlt=self.cfg.get(layoutSection, 'ndgAlt','Visit NDG') -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/controllers/login.py
r3897 r3914 21 21 present login''' 22 22 log.debug("LoginController.index ...") 23 24 # Convenience alias 25 cfg = g.ndg.security.server.ssoservice.cfg 23 26 24 27 # Check the return to URL … … 32 35 try: 33 36 smClnt = SessionMgrClient(uri=session['ndgSec']['h'], 34 tracefile=g.ndg.security.server.ssoservice.cfg.tracefile, 35 **g.ndg.security.server.ssoservice.cfg.wss) 37 tracefile=cfg.tracefile, 38 httpProxyHost=cfg.httpProxyHost, 39 ignoreHttpProxyEnv=cfg.ignoreHttpProxyEnv, 40 **cfg.wss) 36 41 37 42 except Exception, e: … … 73 78 Session Manager following user login""" 74 79 log.debug("LoginController.getCredentials ...") 80 81 # Convenience alias 82 cfg = g.ndg.security.server.ssoservice.cfg 75 83 76 84 # Check the return to URL … … 82 90 83 91 try: 84 smClnt = SessionMgrClient(\ 85 uri=g.ndg.security.server.ssoservice.cfg.smURI, 86 tracefile=g.ndg.security.server.ssoservice.cfg.tracefile, 87 **g.ndg.security.server.ssoservice.cfg.wss) 92 smClnt = SessionMgrClient(uri=cfg.smURI, 93 tracefile=cfg.tracefile, 94 httpProxyHost=cfg.httpProxyHost, 95 ignoreHttpProxyEnv=cfg.ignoreHttpProxyEnv, 96 **cfg.wss) 88 97 89 98 username = request.params['username'] … … 99 108 # Connect to Session Manager 100 109 log.debug('Calling Session Manager "%s" connect for user "%s" ...' % \ 101 ( g.ndg.security.server.ssoservice.cfg.smURI, username))110 (cfg.smURI, username)) 102 111 try: 103 112 sessID = smClnt.connect(username, passphrase=passphrase)[-1] … … 115 124 # Make request for attribute certificate 116 125 attCert = smClnt.getAttCert(sessID=sessID, 117 attAuthorityURI=g.ndg.security.server.ssoservice.cfg.aaURI)126 attAuthorityURI=cfg.aaURI) 118 127 except SessionExpired, e: 119 128 log.info("Session expired getting Attribute Certificate: %s" % e) … … 139 148 140 149 # Make security session details 141 setSecuritySession(h= g.ndg.security.server.ssoservice.cfg.smURI,150 setSecuritySession(h=cfg.smURI, 142 151 u=username, 143 152 org=attCert.issuerName, … … 157 166 this is not necessary.""" 158 167 log.debug("LoginController._redirect...") 168 169 # Convenience alias 170 cfg = g.ndg.security.server.ssoservice.cfg 159 171 160 172 # This is set in index and getCredentials … … 188 200 189 201 # Look-up list of Cert DNs for trusted requestors 190 aaClnt = AttAuthorityClient(\ 191 uri=g.ndg.security.server.ssoservice.cfg.aaURI, 192 tracefile=g.ndg.security.server.ssoservice.cfg.tracefile, 193 **g.ndg.security.server.ssoservice.cfg.wss) 202 aaClnt = AttAuthorityClient(uri=cfg.aaURI, 203 tracefile=cfg.tracefile, 204 httpProxyHost=cfg.httpProxyHost, 205 ignoreHttpProxyEnv=cfg.ignoreHttpProxyEnv, 206 **cfg.wss) 194 207 195 208 HostInfo = aaClnt.getAllHostsInfo() … … 198 211 log.debug(\ 199 212 "Attribute Authority [%s] expecting DN for SSL peer one of: %s" % \ 200 ( g.ndg.security.server.ssoservice.cfg.aaURI, requestServerDN))213 (cfg.aaURI, requestServerDN)) 201 214 202 215 hostCheck = HostCheck(acceptedDNs=requestServerDN, 203 caCertFilePathList=\ 204 g.ndg.security.server.ssoservice.cfg.sslCACertFilePathList) 216 caCertFilePathList=cfg.sslCACertFilePathList) 205 217 206 218 testConnection = HTTPSConnection(returnToURLHostname, -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/controllers/wayf.py
r3892 r3914 29 29 # preserve confidentiality of credentials 30 30 if g.ndg.security.server.ssoservice.cfg.server in c.returnTo: 31 c.returnTo = c.returnTo.replace(g.ndg.security.server.ssoservice.cfg.server, 32 g.ndg.security.server.ssoservice.cfg.sslServer) 31 c.returnTo = c.returnTo.replace(\ 32 g.ndg.security.server.ssoservice.cfg.server, 33 g.ndg.security.server.ssoservice.cfg.sslServer) 33 34 c.b64encReturnTo = urlsafe_b64encode(c.returnTo) 34 35 log.debug(\ … … 39 40 def index(self): 40 41 ''' NDG equivalent to Shibboleth WAYF ''' 42 43 # Convenience alias 44 cfg = g.ndg.security.server.ssoservice.cfg 45 41 46 log.debug("WayfController.index ...") 47 log.debug("Initialising connection to Attribute Authority [%s]" % \ 48 cfg.aaURI) 49 50 try: 51 aaClnt = AttAuthorityClient(uri=cfg.aaURI, 52 tracefile=cfg.tracefile, 53 httpProxyHost=cfg.httpProxyHost, 54 ignoreHttpProxyEnv=cfg.ignoreHttpProxyEnv, 55 **cfg.wss) 56 except Exception, e: 57 c.xml='Error establishing security context. Please report ' + \ 58 'the error to your site administrator' 59 log.error("Initialising AttAuthorityClient for " + \ 60 "getAllHostsInfo call: %s" % e) 61 return render('ndg.security.kid', 'ndg.security.error') 62 63 # Get list of login uris for trusted sites including THIS one 64 log.debug("Calling Attribute Authority getAllHostsInfo for wayf ...") 42 65 43 aaClnt = AttAuthorityClient(\ 44 uri=g.ndg.security.server.ssoservice.cfg.aaURI, 45 tracefile=g.ndg.security.server.ssoservice.cfg.tracefile, 46 **g.ndg.security.server.ssoservice.cfg.wss) 47 48 # Get list of login uris for trusted sites including THIS one 49 log.debug("Calling Attribute Authority getTrustedHostInfo and " + \ 50 "getHostInfo for wayf") 51 52 hosts = aaClnt.getAllHostsInfo() 53 c.providers=dict([(k, v['loginURI']) for k, v in hosts.items()]) 66 hosts = aaClnt.getAllHostsInfo() 67 try: 68 hosts = aaClnt.getAllHostsInfo() 69 except Exception, e: 70 c.xml='Error getting a list of trusted sites for login. ' + \ 71 'Please report the error to your site administrator.' 72 log.error("AttAuthorityClient getAllHostsInfo call: %s" % e) 73 return render('ndg.security.kid', 'ndg.security.error') 74 75 c.providers = dict([(k, v['loginURI']) for k, v in hosts.items()]) 54 76 55 77 session.save() -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/lib/base.py
r3892 r3914 13 13 import ndg.security.server.sso.sso.lib.helpers as h 14 14 import ndg.security.server.sso.sso.model as model 15 from ndg.security.common.pylons.security_util import setSecuritySession, \ 16 session 15 17 16 18 import urllib 17 from urlparse import urlsplit, urlunsplit18 from base64 import urlsafe_b64encode19 20 from ndg.security.common.pylons.security_util import setSecuritySession, \21 SSOServiceQuery22 23 19 import logging 24 20 log = logging.getLogger(__name__) … … 32 28 # is under environ['pylons.routes_dict'] should you want to check 33 29 # the action or route vars here 34 log.debug("BaseController.__call__ ...")30 #log.debug("BaseController.__call__ ...") 35 31 36 32 # construct URL picking up setting of server name from config to … … 48 44 c.requestURL += '?' + query 49 45 50 log.debug("BaseController.__call__: c.requestURL = %s" % c.requestURL)51 46 #log.debug("BaseController.__call__: c.requestURL = %s" % c.requestURL) 47 self._openidHandler(environ) 52 48 53 49 return WSGIController.__call__(self, environ, start_response) 54 50 51 def _openidHandler(self, environ): 52 if 'REMOTE_USER' not in environ: 53 return 54 55 if 'ndgSec' in session and \ 56 environ['REMOTE_USER'] == session['ndgSec']['u']: 57 return 58 59 setSecuritySession(h=None, 60 u=environ['REMOTE_USER'], 61 org=environ['REMOTE_USER'], 62 roles=[], 63 sid=None) 64 session.save() 65 55 66 # Include the '_' function in the public names 56 67 __all__ = [__name for __name in locals().keys() if not __name.startswith('_') \ -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/templates/ndg/security/wayf.kid
r3892 r3914 1 1 <html py:extends="'ndgPage.kid'" xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"> 2 <head> 3 <replace py:replace="pagehead()"/> 4 </head> 5 <body> 6 <div py:replace="header()"/> 7 <div class="wayfContent" style="text-indent:5px"> 2 <div py:def="trustedSitesList()" class="trustedSitesList" style="text-indent:5px"> 8 3 <h4> Where are you from? </h4> 9 <p> You can login in at: 10 <?python 11 # Sort alphabetically 12 providerNames = c.providers.keys() 13 providerNames.sort() 14 ?> 15 <ul py:for="h in providerNames"> 16 <li> <a href="${c.providers[h]}?r=${c.b64encReturnTo}">${h}</a></li> 17 </ul></p> 4 <p> You can login in at a trusted partner site: 5 <?python 6 # Sort alphabetically 7 providerNames = c.providers.keys() 8 providerNames.sort() 9 ?> 10 <ul py:for="h in providerNames"> 11 <li> <a href="${c.providers[h]}?r=${c.b64encReturnTo}">${h}</a></li> 12 </ul> 13 </p> 14 <!-- 18 15 <p>Before clicking on these links, please check that the links redirect to a site 19 16 you trust with your security credentials.</p> 20 17 <p> How can I tell? For any of the above, following login you will be 21 18 redirected back to the URL: <a href="${c.returnTo}">${c.returnTo}</a></p> 22 </div> 19 --> 20 </div> 21 22 <div py:def="openIDSignin()" class="openIDSignin" style="text-indent:5px"> 23 <p>Alternatively, sign in with OpenID:</p> 24 <form action="$g.ndg.security.server.ssoservice.cfg.server/verify" method="post"> 25 <table cellspacing="0" border="0" cellpadding="5"> 26 <tr> 27 <td>OpenID:</td> 28 <td><input type="text" name="openid" value="" class='openid-identifier'/></td> 29 <td align="right"> 30 <input type="submit" name="authform" value="Go"/></td> 31 </tr> 32 </table> 33 </form> 34 </div> 35 36 <head> 37 <style> 38 input.openid-identifier { 39 background: url($g.ndg.security.server.ssoservice.cfg.server/layout/openid-inputicon.gif) no-repeat; 40 background-color: #fff; 41 background-position: 0 50%; 42 padding-left: 18px; 43 } 44 </style> 45 <replace py:replace="pagehead()"/> 46 </head> 47 <body> 48 <div py:replace="header()"/> 49 <replace py:replace="trustedSitesList()"/> 50 <replace py:replace="openIDSignin()"/> 23 51 <div py:replace="footer(showLoginStatus=False)"/> 24 52 </body>
Note: See TracChangeset
for help on using the changeset viewer.