Add multi-tenancy support for SAML

This commit is contained in:
Anamika Aggarwal
2025-07-16 07:49:37 +00:00
committed by Javi Martín
parent 5726bcef07
commit c9bf7797a0
5 changed files with 156 additions and 4 deletions

View File

@@ -16,6 +16,11 @@ module OmniauthTenantSetup
oauth2(env, secrets.wordpress_oauth2_key, secrets.wordpress_oauth2_secret)
end
def saml(env)
saml_auth(env, secrets.saml_sp_entity_id,
secrets.saml_idp_metadata_url, secrets.saml_idp_sso_service_url)
end
private
def oauth(env, key, secret)
@@ -32,6 +37,24 @@ module OmniauthTenantSetup
end
end
def saml_auth(env, sp_entity_id, idp_metadata_url, idp_sso_service_url)
unless Tenant.default?
strategy = env["omniauth.strategy"]
strategy.options[:sp_entity_id] = sp_entity_id if sp_entity_id.present?
strategy.options[:idp_metadata_url] = idp_metadata_url if idp_metadata_url.present?
strategy.options[:idp_sso_service_url] = idp_sso_service_url if idp_sso_service_url.present?
if strategy.options[:issuer].present? && sp_entity_id.present?
strategy.options[:issuer] = sp_entity_id
end
if strategy.options[:idp_metadata].present? && idp_metadata_url.present?
strategy.options[:idp_metadata] = idp_metadata_url
end
end
end
def secrets
Tenant.current_secrets
end