saml_database.rb 874 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class SamlDatabase < OmniAuth::Strategies::SAML
  3. option :name, 'saml'
  4. def initialize(app, *args, &block)
  5. http_type = Setting.get('http_type')
  6. fqdn = Setting.get('fqdn')
  7. # Use meta URL as entity id/issues as it is best practice.
  8. # See: https://community.zammad.org/t/saml-oidc-third-party-authentication/2533/13
  9. entity_id = "#{http_type}://#{fqdn}/auth/saml/metadata"
  10. assertion_consumer_service_url = "#{http_type}://#{fqdn}/auth/saml/callback"
  11. config = Setting.get('auth_saml_credentials') || {}
  12. options = config.reject { |_k, v| v.blank? }
  13. .merge(
  14. assertion_consumer_service_url: assertion_consumer_service_url,
  15. issuer: entity_id,
  16. )
  17. args[0] = options
  18. super
  19. end
  20. end