diff --git a/example/idp/attributemaps/basic.py b/example/attributemaps/basic.py similarity index 100% rename from example/idp/attributemaps/basic.py rename to example/attributemaps/basic.py diff --git a/example/idp/attributemaps/saml_uri.py b/example/attributemaps/saml_uri.py similarity index 100% rename from example/idp/attributemaps/saml_uri.py rename to example/attributemaps/saml_uri.py diff --git a/example/idp/attributemaps/shibboleth_uri.py b/example/attributemaps/shibboleth_uri.py similarity index 100% rename from example/idp/attributemaps/shibboleth_uri.py rename to example/attributemaps/shibboleth_uri.py diff --git a/example/idp/idp_conf.py b/example/idp/idp_conf.py index 045c6e5..250c1ca 100644 --- a/example/idp/idp_conf.py +++ b/example/idp/idp_conf.py @@ -41,7 +41,7 @@ CONFIG={ # This database holds the map between a subjects local identifier and # the identifier returned to a SP #"xmlsec_binary": "/usr/local/bin/xmlsec1", - "attribute_map_dir" : "./attributemaps", + "attribute_map_dir" : "../attributemaps", "logger": { "rotating": { "filename": "idp.log", diff --git a/example/idp2/idp.py b/example/idp2/idp.py index a1303bb..d5db78e 100755 --- a/example/idp2/idp.py +++ b/example/idp2/idp.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +import base64 import re import logging @@ -9,23 +10,24 @@ from hashlib import sha1 from urlparse import parse_qs from Cookie import SimpleCookie -from saml2 import server, BINDING_HTTP_ARTIFACT +from saml2 import server +from saml2 import BINDING_HTTP_ARTIFACT +from saml2 import BINDING_URI +from saml2 import BINDING_PAOS from saml2 import BINDING_SOAP from saml2 import BINDING_HTTP_REDIRECT from saml2 import BINDING_HTTP_POST from saml2 import time_util -from saml2.httputil import Response +from saml2.httputil import Response, NotFound from saml2.httputil import get_post from saml2.httputil import Redirect from saml2.httputil import Unauthorized from saml2.httputil import BadRequest from saml2.httputil import ServiceError from saml2.ident import Unknown -from saml2.s_utils import rndstr +from saml2.s_utils import rndstr, UnknownPrincipal, UnsupportedBinding from saml2.s_utils import PolicyError from saml2.saml import AUTHN_PASSWORD -from saml2.saml import NAMEID_FORMAT_PERSISTENT -from saml2.saml import NameID logger = logging.getLogger("saml2.idp") @@ -113,14 +115,15 @@ def dict2list_of_tuples(d): # ----------------------------------------------------------------------------- -def _operation(environ, start_response, user, _dict, func, binding): +def _operation(environ, start_response, user, _dict, func, binding, + **kwargs): logger.debug("_operation: %s" % _dict) if not _dict: resp = BadRequest('Error parsing request or no request') return resp(environ, start_response) else: return func(environ, start_response, user, _dict["SAMLRequest"], - binding, _dict["RelayState"]) + binding, _dict["RelayState"], **kwargs) def _artifact_oper(environ, start_response, user, _dict, func): if not _dict: @@ -133,6 +136,13 @@ def _artifact_oper(environ, start_response, user, _dict, func): return func(environ, start_response, user, request, BINDING_HTTP_ARTIFACT, _dict["RelayState"]) +def _response(environ, start_response, binding, http_args): + if binding == BINDING_HTTP_ARTIFACT: + resp = Redirect() + else: + resp = Response(http_args["data"], headers=http_args["headers"]) + return resp(environ, start_response) + # ----------------------------------------------------------------------------- AUTHN = (AUTHN_PASSWORD, "http://lingon.catalogix.se/login") @@ -146,7 +156,8 @@ FORM_SPEC = """