Merge pull request #38 from fredrikt/master

example idp bugfix
This commit is contained in:
Roland Hedberg
2013-05-17 09:03:02 -07:00

View File

@@ -306,9 +306,10 @@ class SSO(Service):
_info = self.unpack_redirect() _info = self.unpack_redirect()
try: try:
_info = IDP.ticket[_info["key"]] _key = _info["key"]
_info = IDP.ticket[_key]
self.req_info = _info["req_info"] self.req_info = _info["req_info"]
del IDP.ticket[_info["key"]] del IDP.ticket[_key]
except KeyError: except KeyError:
self.req_info = IDP.parse_authn_request(_info["SAMLRequest"], self.req_info = IDP.parse_authn_request(_info["SAMLRequest"],
BINDING_HTTP_REDIRECT) BINDING_HTTP_REDIRECT)
@@ -832,40 +833,27 @@ def application(environ, start_response):
except KeyError: except KeyError:
user = None user = None
url_patterns = AUTHN_URLS
if not user: if not user:
logger.info("-- No USER --") logger.info("-- No USER --")
for regex, callback in NON_AUTHN_URLS: # insert NON_AUTHN_URLS first in case there is no user
match = re.search(regex, path) url_patterns = NON_AUTHN_URLS + url_patterns
if match is not None:
try:
environ['myapp.url_args'] = match.groups()[0]
except IndexError:
environ['myapp.url_args'] = path
logger.debug("Callback: %s" % (callback,)) for regex, callback in url_patterns:
if isinstance(callback, tuple): match = re.search(regex, path)
cls = callback[0](environ, start_response, user) if match is not None:
func = getattr(cls, callback[1]) try:
return func() environ['myapp.url_args'] = match.groups()[0]
else: except IndexError:
return callback(environ, start_response, user) environ['myapp.url_args'] = path
for regex, callback in AUTHN_URLS:
match = re.search(regex, path) logger.debug("Callback: %s" % (callback,))
if match is not None: if isinstance(callback, tuple):
cls = callback[0](environ, start_response, user)
func = getattr(cls, callback[1])
return func()
else:
for regex, callback in AUTHN_URLS:
match = re.search(regex, path)
if match is not None:
try:
environ['myapp.url_args'] = match.groups()[0]
except IndexError:
environ['myapp.url_args'] = path
cls = callback[0](environ, start_response, user) cls = callback[0](environ, start_response, user)
func = getattr(cls, callback[1]) func = getattr(cls, callback[1])
return func() return func()
return callback(environ, start_response, user)
return not_found(environ, start_response) return not_found(environ, start_response)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
@@ -900,4 +888,4 @@ if __name__ == '__main__':
SRV = make_server('', PORT, application) SRV = make_server('', PORT, application)
print "IdP listening on port: %s" % PORT print "IdP listening on port: %s" % PORT
SRV.serve_forever() SRV.serve_forever()