Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow secure session cookies through proxy or to localhost #41

Merged
Merged
Changes from 2 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
5 changes: 4 additions & 1 deletion lib/rack/session/abstract/id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def initialize(app, options = {})
@app = app
@default_options = self.class::DEFAULT_OPTIONS.merge(options)
@key = @default_options.delete(:key)
@trust_proxy = @default_options.delete(:trust_proxy)
@cookie_only = @default_options.delete(:cookie_only)
@same_site = @default_options.delete(:same_site)
initialize_sid
Expand Down Expand Up @@ -368,7 +369,9 @@ def force_options?(options)

def security_matches?(request, options)
return true unless options[:secure]
request.ssl?
# OK to send a secure token over ssl, or to local host
# or if the instance is running behind a proxy that handles ssl
request.ssl? || request.host == 'localhost' || @trust_proxy
ioquatix marked this conversation as resolved.
Show resolved Hide resolved
end

# Acquires the session from the environment and the session id from
Expand Down