Sha256: 8ab6f58b49299685fe956a965ff4cbe414947eeb66176306d6520bb420f2a487

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require "kingsman/jets/routes"
require "kingsman/jets/warden_compat"

module Kingsman
  class Engine < ::Jets::Engine
    config.kingsman = ActiveSupport::OrderedOptions.new

    config.app_middleware.use Warden::Manager do |manager|
      Kingsman.warden_config = manager
    end

    initializer "kingsman.url_helpers" do
      Kingsman.include_helpers(Kingsman::Controllers)
    end

    initializer "kingsman.omniauth", after: :load_config_initializers, before: :build_middleware_stack do |app|
      Kingsman.omniauth_configs.each do |provider, config|
        app.middleware.use config.strategy_class, *config.args do |strategy|
          config.strategy = strategy
        end
      end

      if Kingsman.omniauth_configs.any?
        Kingsman.include_helpers(Kingsman::OmniAuth)
      end
    end

    initializer "kingsman.secret_key" do |app|
      Kingsman.secret_key ||= Kingsman::SecretKeyFinder.new(app).find

      Kingsman.token_generator ||=
        if secret_key = Kingsman.secret_key
          Kingsman::TokenGenerator.new(
            ActiveSupport::CachingKeyGenerator.new(ActiveSupport::KeyGenerator.new(secret_key))
          )
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kingsman-0.1.1 lib/kingsman/jets.rb
kingsman-0.1.0 lib/kingsman/jets.rb