<commit_before>module Thincloud
  module Authentication
    # Public: Initialize the Rails engine
    class Engine < ::Rails::Engine
      isolate_namespace Thincloud::Authentication

      require "thincloud/authentication/configuration"

      initializer "thincloud.authentication.require_dependencies" do
        require_dependency "thincloud/authentication/authenticatable_controller"
        require_dependency "thincloud/authentication/identifiable_user"
      end

      initializer "thincloud.authentication.omniauth.middleware" do |app|
        require "omniauth"
        require "omniauth-identity"

        config = Thincloud::Authentication.configuration || Configuration.new
        strategies = config.providers.keys
        strategies.each do |strategy|
          lib = config.providers[strategy][:require] || "omniauth-#{strategy}"
          require lib
        end

        app.middleware.use ::OmniAuth::Builder do
          # always provide the Identity strategy
          provider :identity, fields: [:email], model: Identity,
            on_failed_registration: RegistrationsController.action(:new)

          strategies.each do |strategy|
            provider strategy, ENV["#{strategy.to_s.upcase}_CONSUMER_KEY"],
              ENV["#{strategy.to_s.upcase}_CONSUMER_SECRET"],
              fields: config.providers[strategy][:fields],
              scope: config.providers[strategy][:scopes]
          end
        end
      end

      initializer "thincloud.authentication.omniauth.logger" do
        ::OmniAuth.config.logger = ::Rails.logger
      end

      initializer "thincloud.authentication.omniauth.failure_endpoint" do
        ::OmniAuth.config.on_failure = -> env do
          ::OmniAuth::FailureEndpoint.new(env).redirect_to_failure
        end
      end
<commit_msg>rename `config` to `conf` to avoid scope collision<commit_after>module Thincloud
  module Authentication

    # Public: Initialize the Rails engine
    class Engine < ::Rails::Engine
      isolate_namespace Thincloud::Authentication

      require "thincloud/authentication/configuration"

      initializer "thincloud.authentication.require_dependencies" do
        require_dependency "thincloud/authentication/authenticatable_controller"
        require_dependency "thincloud/authentication/identifiable_user"
      end

      initializer "thincloud.authentication.omniauth.middleware" do |app|
        require "omniauth"
        require "omniauth-identity"

        conf = Thincloud::Authentication.configuration || Configuration.new
        strategies = conf.providers.keys
        strategies.each do |strategy|
          lib = conf.providers[strategy][:require] || "omniauth-#{strategy}"
          require lib
        end

        app.middleware.use ::OmniAuth::Builder do
          # always provide the Identity strategy
          provider :identity, fields: [:email], model: Identity,
            on_failed_registration: RegistrationsController.action(:new)

          strategies.each do |strategy|
            provider strategy, ENV["#{strategy.to_s.upcase}_CONSUMER_KEY"],
              ENV["#{strategy.to_s.upcase}_CONSUMER_SECRET"],
              fields: conf.providers[strategy][:fields],
              scope: conf.providers[strategy][:scopes]
          end
        end
      end

      initializer "thincloud.authentication.omniauth.logger" do
        ::OmniAuth.config.logger = ::Rails.logger
      end

      initializer "thincloud.authentication.omniauth.failure_endpoint" do
        ::OmniAuth.config.on_failure = -> env do
          ::OmniAuth::FailureEndpoint.new(env).redirect_to_failure
        end
      end

{'fraction_non_alphanumeric': 0.08975770925110133, 'fraction_numerical': 0.0, 'mean_word_length': 2.8855614973262034, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2542049', 'n_tokens_mistral': 1005, 'n_tokens_neox': 962, 'n_words': 189}