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

Set secure flag for remember_me cookie #295

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

paderinandrey
Copy link

@paderinandrey paderinandrey commented Dec 6, 2021

Added the ability to set the secure flag for the remember_me cookie

Please ensure your pull request includes the following:

  • Description of changes
  • Update to CHANGELOG.md with short description and link to pull request
  • Changes have related RSpec tests that ensure functionality does not break

@joshbuker
Copy link
Member

Ah, so this allows users to set secure cookies to true without needing force_ssl = true.

Just to sanity check, @paderinandrey does your use-case prevent you from using force_ssl (which also enables secure cookies)?

@joshbuker joshbuker added the enhancement New feature or request label Dec 6, 2021
Copy link
Member

@joshbuker joshbuker left a comment

Choose a reason for hiding this comment

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

This change is potentially dangerous, depending on how Rails handles the interaction between force_ssl and secure: false. Needs verification.

@@ -71,7 +71,8 @@ def set_remember_me_cookie!(user)
value: user.send(user.sorcery_config.remember_me_token_attribute_name),
expires: user.send(user.sorcery_config.remember_me_token_expires_at_attribute_name),
httponly: Config.remember_me_httponly,
domain: Config.cookie_domain
domain: Config.cookie_domain,
secure: Config.remember_me_secure
Copy link
Member

Choose a reason for hiding this comment

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

I'd be worried that this has the potential to overwrite the default of secure: true when using force_ssl. We'll need to double check that interaction before merging this in. Ideally, adding a test or two.

def merge_remember_me_defaults!
@defaults.merge!(:@remember_me_httponly => true)
@defaults.merge!(:@remember_me_httponly => true, :@remember_me_secure => false)
Copy link
Member

Choose a reason for hiding this comment

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

nil would likely be a safer default here. Still would need to sanity check how this interacts with force_ssl either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants