Class: OmniAuth::FailureEndpoint
- Inherits:
-
Object
- Object
- OmniAuth::FailureEndpoint
- Defined in:
- lib/omniauth/failure_endpoint.rb
Overview
This simple Rack endpoint that serves as the default
'failure' mechanism for OmniAuth. If a strategy fails for
any reason this endpoint will be invoked. The default behavior
is to redirect to /auth/failure
except in the case of
a development RACK_ENV
, in which case an exception will
be raised.
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(env) ⇒ FailureEndpoint
constructor
A new instance of FailureEndpoint.
- #origin_query_param ⇒ Object
- #raise_out! ⇒ Object
- #redirect_to_failure ⇒ Object
- #strategy_name_query_param ⇒ Object
Constructor Details
#initialize(env) ⇒ FailureEndpoint
Returns a new instance of FailureEndpoint.
15 16 17 |
# File 'lib/omniauth/failure_endpoint.rb', line 15 def initialize(env) @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
9 10 11 |
# File 'lib/omniauth/failure_endpoint.rb', line 9 def env @env end |
Class Method Details
.call(env) ⇒ Object
11 12 13 |
# File 'lib/omniauth/failure_endpoint.rb', line 11 def self.call(env) new(env).call end |
Instance Method Details
#call ⇒ Object
19 20 21 22 |
# File 'lib/omniauth/failure_endpoint.rb', line 19 def call raise_out! if OmniAuth.config.failure_raise_out_environments.include?(ENV['RACK_ENV'].to_s) redirect_to_failure end |
#origin_query_param ⇒ Object
40 41 42 43 44 |
# File 'lib/omniauth/failure_endpoint.rb', line 40 def origin_query_param return '' unless env['omniauth.origin'] "&origin=#{Rack::Utils.escape(env['omniauth.origin'])}" end |
#raise_out! ⇒ Object
24 25 26 |
# File 'lib/omniauth/failure_endpoint.rb', line 24 def raise_out! raise(env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type'])) end |
#redirect_to_failure ⇒ Object
28 29 30 31 32 |
# File 'lib/omniauth/failure_endpoint.rb', line 28 def redirect_to_failure = env['omniauth.error.type'] new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{}#{origin_query_param}#{strategy_name_query_param}" Rack::Response.new(['302 Moved'], 302, 'Location' => new_path).finish end |
#strategy_name_query_param ⇒ Object
34 35 36 37 38 |
# File 'lib/omniauth/failure_endpoint.rb', line 34 def strategy_name_query_param return '' unless env['omniauth.error.strategy'] "&strategy=#{env['omniauth.error.strategy'].name}" end |