Sha256: bf6f768162223bcc4e902981ae667fbaf8356c66379ce03bd757ca24320919e8

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module RailsSso
  class Engine < Rails::Engine
    initializer 'sso.helpers' do
      ActiveSupport.on_load(:action_controller) do
        include RailsSso::Helpers
      end
    end

    initializer 'sso.omniauth', after: :load_config_initializers, before: :build_middleware_stack do |app|
      if RailsSso.provider_name
        RailsSso.oauth2_strategy_class.class_eval do
          def setup_phase
            setup_sso!

            super
          end

          def other_phase
            setup_sso!

            call_app!
          end

          def setup_sso!
            env['sso'] ||= RailsSso::App.new(self, session)
          end
        end

        app.config.middleware.use OmniAuth::Builder do
          provider RailsSso.provider_name,
            RailsSso.provider_key,
            RailsSso.provider_secret,
            callback_path: RailsSso.provider_callback_path
        end

        app.config.middleware.insert_after OmniAuth::Builder, Warden::Manager do |manager|
          manager.default_strategies :sso
          manager.failure_app = RailsSso::FailureApp
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_sso-0.4.0 lib/rails_sso/engine.rb