mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-06-08 01:42:37 -04:00
feat: configure SP certificate and private key via SAMLConfiguration (#1531)
This commit is contained in:
@@ -53,16 +53,12 @@ def build_sp_config(request, provider_config, org):
|
||||
"binding": OneLogin_Saml2_Constants.BINDING_HTTP_REDIRECT,
|
||||
},
|
||||
}
|
||||
if _sp_config.get("x509cert"):
|
||||
sp_config["x509cert"] = _sp_config["x509cert"]
|
||||
if _sp_config.get("private_key"):
|
||||
sp_config["privateKey"] = _sp_config["private_key"]
|
||||
|
||||
avd = provider_config.get("advanced", {})
|
||||
if avd.get("x509cert") is not None:
|
||||
sp_config["x509cert"] = avd["x509cert"]
|
||||
|
||||
if avd.get("x509cert_new"):
|
||||
sp_config["x509certNew"] = avd["x509cert_new"]
|
||||
|
||||
if avd.get("private_key") is not None:
|
||||
sp_config["privateKey"] = avd["private_key"]
|
||||
|
||||
if avd.get("name_id_format") is not None:
|
||||
sp_config["NameIDFormat"] = avd["name_id_format"]
|
||||
|
||||
|
||||
@@ -154,7 +154,9 @@ sls = SLSView.as_view()
|
||||
class MetadataView(SAMLViewMixin, View):
|
||||
def dispatch(self, request, organization_slug):
|
||||
provider = self.get_provider(organization_slug)
|
||||
config = build_saml_config(self.request, provider.app.settings, organization_slug)
|
||||
custom_configuration = provider.app.saml_configurations.first()
|
||||
provider_config = custom_configuration.saml_provider_settings if custom_configuration else provider.app.settings
|
||||
config = build_saml_config(self.request, provider_config, organization_slug)
|
||||
saml_settings = OneLogin_Saml2_Settings(settings=config, sp_validation_only=True)
|
||||
metadata = saml_settings.get_sp_metadata()
|
||||
errors = saml_settings.validate_metadata(metadata)
|
||||
|
||||
Reference in New Issue
Block a user