Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def self.defaults
:logger => default_logger,
:allowed_request_methods => [:get, :post],
:mock_auth => {:default => AuthHash.new('provider' => 'default', 'uid' => '1234', 'info' => {'name' => 'Example User'})},
:session_key => 'rack.session',
}
end

Expand Down Expand Up @@ -116,7 +117,7 @@ def add_camelization(name, camelized)
end

attr_writer :on_failure, :before_callback_phase, :before_options_phase, :before_request_phase
attr_accessor :failure_raise_out_environments, :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host, :camelizations, :logger
attr_accessor :failure_raise_out_environments, :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host, :camelizations, :logger, :session_key
end

def self.config
Expand Down
12 changes: 6 additions & 6 deletions lib/omniauth/strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def call(env)
#
# @param env [Hash] The Rack environment.
def call!(env) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
unless env['rack.session']
unless env[OmniAuth.config.session_key]
error = OmniAuth::NoSessionError.new('You must provide a session to use OmniAuth.')
fail(error)
end
Expand Down Expand Up @@ -208,9 +208,9 @@ def request_call # rubocop:disable CyclomaticComplexity, MethodLength, Perceived
call_app!
else
if request.params['origin']
env['rack.session']['omniauth.origin'] = request.params['origin']
session['omniauth.origin'] = request.params['origin']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not instance variable in origin code, I feel maybe there are some reason to not use instance variable (but author only knows...).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't nope. It seems to use the default attribute accessor so it basically does the same thing. I updated it for clarity and it does not break the test suite, that's good enough for me ^^

elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
session['omniauth.origin'] = env['HTTP_REFERER']
end
request_phase
end
Expand Down Expand Up @@ -268,9 +268,9 @@ def mock_request_call
session['omniauth.params'] = request.params
OmniAuth.config.before_request_phase.call(env) if OmniAuth.config.before_request_phase
if request.params['origin']
@env['rack.session']['omniauth.origin'] = request.params['origin']
session['omniauth.origin'] = request.params['origin']
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
@env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
session['omniauth.origin'] = env['HTTP_REFERER']
end

redirect(callback_url)
Expand Down Expand Up @@ -437,7 +437,7 @@ def script_name
end

def session
@env['rack.session']
@env[OmniAuth.config.session_key]
end

def request
Expand Down
4 changes: 2 additions & 2 deletions lib/omniauth/test/phony_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def initialize(app)
end

def call(env)
@session ||= (env['rack.session'] || {})
env['rack.session'] = @session
@session ||= (env[OmniAuth.config.session_key] || {})
env[OmniAuth.config.session_key] = @session
@app.call(env)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/omniauth/test/strategy_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def app_response
end

def session
last_request.env['rack.session']
last_request.env[OmniAuth.config.session_key]
end

def strategy
Expand Down