From e707db89524ab240afa718bb15ab9ad28e67c6c6 Mon Sep 17 00:00:00 2001 From: Camille Rodriguez Date: Mon, 25 Apr 2022 15:52:23 -0500 Subject: [PATCH] Add configuration option for entityID. Sets the entityID in the service provider metadata file. If not provided, entityID is autogenerated. Change-Id: I75fc734661575e809f92aea17b75530001b2db73 --- src/config.yaml | 7 +++++++ src/lib/charm/openstack/keystone_saml_mellon.py | 9 +++++++++ src/templates/mellon-sp-metadata.xml | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/config.yaml b/src/config.yaml index 2b0d1c5..0d455eb 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -5,6 +5,13 @@ options: description: | Protocol name to use for URL and generation. Must match the one that will be configured via OS-FEDERATION API. + entity-id-url: + type: string + default: + description: | + Optional field to provide the entity ID to be used in the service + provider metadata. If set to default (""), entity ID is generated + automatically. idp-name: type: string default: 'myidp' diff --git a/src/lib/charm/openstack/keystone_saml_mellon.py b/src/lib/charm/openstack/keystone_saml_mellon.py index e0f3522..f606ce6 100644 --- a/src/lib/charm/openstack/keystone_saml_mellon.py +++ b/src/lib/charm/openstack/keystone_saml_mellon.py @@ -131,6 +131,15 @@ class KeystoneSAMLMellonConfigurationAdapter( def supported_nameid_formats(self): return self.nameid_formats.split(',') + @property + def entity_id(self): + if self.entity_id_url is None: + # Generate entity ID automatically + return '{}{}'.format(self.keystone_fid_service_provider.base_url, + self.sp_auth_path) + else: + return self.entity_id_url + IDP_METADATA_INVALID = ('idp-metadata resource is not a well-formed' ' xml file') IDP_METADATA_URL_ERROR = ('an error has occurred during idp-metadata-url' diff --git a/src/templates/mellon-sp-metadata.xml b/src/templates/mellon-sp-metadata.xml index 93f5594..1b6b9e0 100644 --- a/src/templates/mellon-sp-metadata.xml +++ b/src/templates/mellon-sp-metadata.xml @@ -1,5 +1,5 @@