diff options
author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-07-07 13:38:39 +0300 |
---|---|---|
committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-07-10 20:10:51 +0300 |
commit | 0c1873da1f280d4921b9c9b3da9126388d75e701 (patch) | |
tree | d12375c1278a33ad8155f7da547e7c6a9fd4b0f2 /src/saml2/metadata.py | |
parent | 1d7d4f820886c3d84ee06ea36b4e6b99c8ff49d5 (diff) | |
download | pysaml2-0c1873da1f280d4921b9c9b3da9126388d75e701.tar.gz |
Differentiate between metadata NameIDFormat and AuthnRequest NameIDPolicy Format
The `name_id_format` configuration option is used to define
1. the value of the `<NameIDFormat>` metadata element
2. and the value of the `<NameIDPolicy>` `Format` attribute in an `AuthnRequest`
The configuration option to set what the value of `<NameIDFormat>` element is in the
metadata should be different from the configuration option to specify what should be
requested in an `AuthnRequest` through the `<NameIDPolicy Format="...">` attribute.
Introduce a new option (`name_id_policy_format`), or use the same name but scoped in a
specific section for metadata and AuthnRequest.
On the side of this, pysaml2 defaults to _transient_ as the `<NameIDPolicy
Format="...">` attribute value. To omit requesting a value for the `<NameIDPolicy
Format="">` attribute the value `"None"` (a string) must be set in the configuration.
This is unintuitive. It is better to be explicit and set transient to request a
transient NameID, than not setting a value and requesting transient by default. If no
value is set, no specific `<NameIDPolicy Format="...">` should be requested.
- Refactor the name_id_format usage
- Add name_id_policy_format configuration option
- Remove the "None" convention value
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Diffstat (limited to 'src/saml2/metadata.py')
-rw-r--r-- | src/saml2/metadata.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/saml2/metadata.py b/src/saml2/metadata.py index b2317131..d80b41ac 100644 --- a/src/saml2/metadata.py +++ b/src/saml2/metadata.py @@ -379,13 +379,15 @@ def do_extensions(mname, item): def _do_nameid_format(cls, conf, typ): - namef = conf.getattr("name_id_format", typ) - if namef: - if isinstance(namef, six.string_types): - ids = [md.NameIDFormat(namef)] - else: - ids = [md.NameIDFormat(text=form) for form in namef] - setattr(cls, "name_id_format", ids) + name_id_format = conf.getattr("name_id_format", typ) + if not name_id_format: + return + + if isinstance(name_id_format, six.string_types): + name_id_format = [name_id_format] + + formats = [md.NameIDFormat(text=format) for format in name_id_format] + setattr(cls, "name_id_format", formats) def do_endpoints(conf, endpoints): |