required_attributes.rb 717 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Setting::Validation::Saml::RequiredAttributes < Setting::Validation::Base
  3. REQUIRED_ATTRIBUTES = %i[idp_sso_target_url idp_slo_service_url idp_cert name_identifier_format].freeze
  4. def run
  5. return result_success if value.blank? || value.deep_symbolize_keys.keys.eql?([:display_name])
  6. msg = check_prerequisites
  7. return result_failed(msg) if !msg.nil?
  8. result_success
  9. end
  10. private
  11. def check_prerequisites
  12. return "One of the required attributes #{REQUIRED_ATTRIBUTES.map { |e| "'#{e}'" }.join(', ')} is missing." if REQUIRED_ATTRIBUTES.any? { |key| !value.key?(key) || value[key].blank? }
  13. nil
  14. end
  15. end