<commit_before>require 'omniauth/enterprise'

module OmniAuth
  module Strategies
    class SAML
      include OmniAuth::Strategy
      autoload :AuthRequest,      'omniauth/strategies/saml/auth_request'
      autoload :AuthResponse,     'omniauth/strategies/saml/auth_response'
      autoload :ValidationError,  'omniauth/strategies/saml/validation_error'
      autoload :XMLSecurity,      'omniauth/strategies/saml/xml_security'
      
      @@settings = {}
      
      def initialize(app, options={})
        super(app, :saml)
        @@settings = {
          :assertion_consumer_service_url => options[:assertion_consumer_service_url],
          :issuer                         => options[:issuer],
          :idp_sso_target_url             => options[:idp_sso_target_url],
          :idp_cert_fingerprint           => options[:idp_cert_fingerprint],
          :name_identifier_format         => options[:name_identifier_format] || "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
        }
      end
          
      def request_phase
        request = OmniAuth::Strategies::SAML::AuthRequest.new
        redirect(request.create(@@settings))
      end
      
      def callback_phase
        begin
          response = OmniAuth::Strategies::SAML::AuthResponse.new(request.params['SAMLResponse'])
          response.settings = @@settings
          @name_id  = response.name_id
          return fail!(:invalid_ticket, 'Invalid SAML Ticket') if @name_id.nil? || @name_id.empty?
          super
        rescue ArgumentError => e
          fail!(:invalid_ticket, 'Invalid SAML Response')
        end        
      end
      
      def auth_hash
        OmniAuth::Utils.deep_merge(super, {
          'uid' => @name_id
        })
      end  
            
    end
  end
end<commit_msg>allow SAML strategy to have a custom name<commit_after>require 'omniauth/enterprise'

module OmniAuth
  module Strategies
    class SAML
      include OmniAuth::Strategy
      autoload :AuthRequest,      'omniauth/strategies/saml/auth_request'
      autoload :AuthResponse,     'omniauth/strategies/saml/auth_response'
      autoload :ValidationError,  'omniauth/strategies/saml/validation_error'
      autoload :XMLSecurity,      'omniauth/strategies/saml/xml_security'

      @@settings = {}

      def initialize(app, options={})
        super( app, (options[:name] || :saml) )
        @@settings = {
          :assertion_consumer_service_url => options[:assertion_consumer_service_url],
          :issuer                         => options[:issuer],
          :idp_sso_target_url             => options[:idp_sso_target_url],
          :idp_cert_fingerprint           => options[:idp_cert_fingerprint],
          :name_identifier_format         => options[:name_identifier_format] || "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
        }
      end

      def request_phase
        request = OmniAuth::Strategies::SAML::AuthRequest.new
        redirect(request.create(@@settings))
      end

      def callback_phase
        begin
          response = OmniAuth::Strategies::SAML::AuthResponse.new(request.params['SAMLResponse'])
          response.settings = @@settings
          @name_id  = response.name_id
          return fail!(:invalid_ticket, 'Invalid SAML Ticket') if @name_id.nil? || @name_id.empty?
          super
        rescue ArgumentError => e
          fail!(:invalid_ticket, 'Invalid SAML Response')
        end
      end

      def auth_hash
        OmniAuth::Utils.deep_merge(super, {
          'uid' => @name_id
        })
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.10095078299776286, 'fraction_numerical': 0.0011185682326621924, 'mean_word_length': 2.355534709193246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3304604', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1053, 'n_words': 174}