<commit_before>class UserMode::SamlAuthStrategy < UserMode::MultiUser
  def set_auth_provider(omniauth)
    omniauth.provider :saml,
      # TODO: change the :assertion_consumer_service_url, the :issuer and the :slo_default_relay_state:
      # =>  1. we can not call any Organization method since there is none instantiated yet and
      # =>  2. we must use the absolut path to generate the right SAML metadata to set up the federation with the IdP
      :assertion_consumer_service_url     => "http://central.#{Rails.configuration.domain}:3000/auth/saml/callback",
      :issuer                             => "http://central.#{Rails.configuration.domain}:3000/auth/saml",
      :idp_sso_target_url                 => Rails.configuration.saml_idp_sso_target_url,
      :idp_slo_target_url                 => Rails.configuration.saml_idp_slo_target_url,
      :slo_default_relay_state            => "http://central.#{Rails.configuration.domain}:3000",
      :idp_cert                           => File.read('./saml.crt'),
      :attribute_service_name             => 'Mumuki',
      :request_attributes                 => [
        { :name => 'email', :name_format => 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', :friendly_name => 'Email address' },
        { :name => 'name', :name_format => 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', :friendly_name => 'Full name' },
        { :name => 'image', :name_format => 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', :friendly_name => 'Avatar image' }
      ],
      :attribute_statements               => {
        name: [Rails.configuration.saml_translation_name || "name"],
        email: [Rails.configuration.saml_translation_email || "email"],
        image: [Rails.configuration.saml_translation_image || "image"]
      }
  end

  def protect_from_forgery(controller)
    # Do nothing (do not protect): the IdP calls the assertion_url via POST and without the CSRF token
  end

  def auth_link
    # Was using Organization.url_for('/auth/saml/') but the port got lost (is it a bug?)
    'href="http://central.' + Rails.configuration.domain + ':3000/auth/saml/"'
  end

  def logout_redirection_url(controller)
    "http://central.localmumuki.io:3000/auth/saml/spslo"
  end

end<commit_msg>Specyfing the single_logout_service_url and removing hardcoded URLs<commit_after>class UserMode::SamlAuthStrategy < UserMode::MultiUser
  def set_auth_provider(omniauth)
    omniauth.provider :saml,
      # TODO: change the :assertion_consumer_service_url, the :issuer and the :slo_default_relay_state:
      # =>  1. we can not call any Organization method since there is none instantiated yet and
      # =>  2. we must use the absolut path to generate the right SAML metadata to set up the federation with the IdP
      :assertion_consumer_service_url     => "http://#{Rails.configuration.domain}:3000/auth/saml/callback",
      :single_logout_service_url          => "http://#{Rails.configuration.domain}:3000/auth/saml/slo",
      :issuer                             => "http://#{Rails.configuration.domain}:3000/auth/saml",
      :idp_sso_target_url                 => Rails.configuration.saml_idp_sso_target_url,
      :idp_slo_target_url                 => Rails.configuration.saml_idp_slo_target_url,
      :slo_default_relay_state            => "http://#{Rails.configuration.domain}:3000",
      :idp_cert                           => File.read('./saml.crt'),
      :attribute_service_name             => 'Mumuki',
      :request_attributes                 => [
        { :name => 'email', :name_format => 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', :friendly_name => 'Email address' },
        { :name => 'name', :name_format => 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', :friendly_name => 'Full name' },
        { :name => 'image', :name_format => 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', :friendly_name => 'Avatar image' }
      ],
      :attribute_statements               => {
        name: [Rails.configuration.saml_translation_name || "name"],
        email: [Rails.configuration.saml_translation_email || "email"],
        image: [Rails.configuration.saml_translation_image || "image"]
      }
  end

  def protect_from_forgery(controller)
    # Do nothing (do not protect): the IdP calls the assertion_url via POST and without the CSRF token
  end

  def auth_link
    "href=#{Organization.url_for('/auth/saml/')}"
  end

  def logout_redirection_url(controller)
    Organization.url_for('/auth/saml/spslo')
  end

end
{'fraction_non_alphanumeric': 0.12555163283318624, 'fraction_numerical': 0.01147396293027361, 'mean_word_length': 3.0509383378016084, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3388576', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1402, 'n_words': 277}