Sha256: 3801360608d114a45b3275b0bdb8c855652a28654e56de3ffa089568ffb5f0d8

Contents?: true

Size: 1.1 KB

Versions: 17

Compression:

Stored size: 1.1 KB

Contents

require "action_controller/metal"
require 'rails'

# Failure application that will be called every time :warden is thrown from
# any strategy or hook.
module GDS
  module SSO
    class FailureApp < ActionController::Metal
      include ActionController::RackDelegation
      include ActionController::UrlFor
      include ActionController::Redirecting
      include Rails.application.routes.url_helpers

      def self.call(env)
        if ! ::GDS::SSO::ApiAccess.api_call?(env)
          action(:redirect).call(env)
        end
      end

      def redirect
        store_location!
        redirect_to '/auth/gds'
      end

      # Stores requested uri to redirect the user after signing in. We cannot use
      # scoped session provided by warden here, since the user is not authenticated
      # yet, but we still need to store the uri based on scope, so different scopes
      # would never use the same uri to redirect.

      # TOTALLY NOT DOING THE SCOPE THING. PROBABLY SHOULD.
      def store_location!
        session["return_to"] = env['warden.options'][:attempted_path] if request.get?
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gds-sso-9.2.7 lib/gds-sso/failure_app.rb
gds-sso-9.2.6 lib/gds-sso/failure_app.rb
gds-sso-9.2.5 lib/gds-sso/failure_app.rb
gds-sso-9.2.4 lib/gds-sso/failure_app.rb
gds-sso-9.2.3 lib/gds-sso/failure_app.rb
gds-sso-9.2.2 lib/gds-sso/failure_app.rb
gds-sso-9.2.1 lib/gds-sso/failure_app.rb
gds-sso-9.2.0 lib/gds-sso/failure_app.rb
gds-sso-9.1.2 lib/gds-sso/failure_app.rb
gds-sso-9.1.1 lib/gds-sso/failure_app.rb
gds-sso-9.1.0 lib/gds-sso/failure_app.rb
gds-sso-9.0.0 lib/gds-sso/failure_app.rb
gds-sso-8.0.0 lib/gds-sso/failure_app.rb
gds-sso-7.0.0 lib/gds-sso/failure_app.rb
gds-sso-6.0.0 lib/gds-sso/failure_app.rb
gds-sso-5.0.0 lib/gds-sso/failure_app.rb
gds-sso-4.0.0 lib/gds-sso/failure_app.rb