Skip to content

Commit cbb2f76

Browse files
author
Rebecka Gulliksson
committed
Allow configuration of which attribute profile to use in SAML backend and frontend.
1 parent 55fa30c commit cbb2f76

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ Common configuration parameters:
151151
| `key_file` | string | `pki/key.pem` | path to private key used for signing(backend)/decrypting(frontend) SAML2 assertions |
152152
| `cert_file` | string | `pki/cert.pem` | path to certificate for the public key associated with the private key in `key_file` |
153153
| `metadata["local"]` | string[] | `[metadata/entity.xml]` | list of paths to metadata for all service providers (frontend)/identity providers (backend) communicating with the proxy |
154+
| `attribute_profile` | string | `saml` | attribute profile to use for mapping attributes from/to response
154155

155156
The metadata could be loaded in multiple ways in the table above it's loaded from a static
156157
file by using the key "local". It's also possible to load read the metadata from a remote URL.

src/satosa/backends/saml2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(self, outgoing, internal_attributes, config):
7070
self.sp = Base(sp_config)
7171
self.idp_disco_query_param = "entityID"
7272
self.config = config
73+
self.attribute_profile = config.get("attribute_profile", "saml")
7374
self.bindings = [BINDING_HTTP_REDIRECT, BINDING_HTTP_POST]
7475
self.discosrv = None
7576
self.converter = DataConverter(internal_attributes)
@@ -288,7 +289,7 @@ def _translate_response(self, response, state):
288289
raise SATOSAAuthenticationError from error
289290
internal_resp.set_user_id(user_id)
290291

291-
internal_resp.add_attributes(self.converter.to_internal("saml", response.ava))
292+
internal_resp.add_attributes(self.converter.to_internal(self.attribute_profile, response.ava))
292293

293294
satosa_logging(LOGGER, logging.DEBUG,
294295
"received attributes:\n%s" % json.dumps(response.ava, indent=4), state)

src/satosa/frontends/saml2.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def __init__(self, auth_req_callback_func, internal_attributes, conf):
4242
self.base = conf["base"]
4343
self.state_id = conf["state_id"]
4444
self.acr_mapping = conf.get("acr_mapping")
45+
self.attribute_profile = conf.get("attribute_profile", "saml")
4546
self.response_bindings = None
4647
self.idp = None
4748

@@ -304,8 +305,9 @@ def get_filter_attributes(self, idp, idp_policy, sp_entity_id, state):
304305
for aconv in attrconvs:
305306
if aconv.name_format == name_format:
306307
attribute_filter = list(
307-
idp_policy.restrict(aconv._to, sp_entity_id, idp.metadata).keys())
308-
attribute_filter = self.converter.to_internal_filter("saml", attribute_filter, True)
308+
idp_policy.restrict(aconv._to, sp_entity_id, idp.metadata).keys())
309+
attribute_filter = self.converter.to_internal_filter(self.attribute_profile,
310+
attribute_filter, True)
309311
satosa_logging(LOGGER, logging.DEBUG, "Filter: %s" % attribute_filter, state)
310312
return attribute_filter
311313

@@ -325,7 +327,8 @@ def _handle_authn_response(self, context, internal_response, idp):
325327
request_state = self.load_state(context.state)
326328

327329
resp_args = request_state["resp_args"]
328-
ava = self.converter.from_internal("saml", internal_response.get_attributes())
330+
ava = self.converter.from_internal(self.attribute_profile,
331+
internal_response.get_attributes())
329332

330333
auth_info = {}
331334
if self.acr_mapping:

0 commit comments

Comments
 (0)