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

Limit remember cookie to httponly #87

Open
stevepolitodesign opened this issue Feb 25, 2022 · 1 comment
Open

Limit remember cookie to httponly #87

stevepolitodesign opened this issue Feb 25, 2022 · 1 comment

Comments

@stevepolitodesign
Copy link
Owner

stevepolitodesign commented Feb 25, 2022

Before

def remember(active_session)
cookies.permanent.encrypted[:remember_token] = active_session.remember_token
end

After

def remember(active_session)
  cookies.permanent.encrypted[:remember_token] = { value: active_session.remember_token, httponly: true }
end

Issues

set httponly cookie

@stevepolitodesign stevepolitodesign self-assigned this Feb 25, 2022
@stevepolitodesign
Copy link
Owner Author

We can update this test to include the following:

test "should remember user when logging in" do
assert_nil cookies[:remember_token]
post login_path, params: {
user: {
email: @confirmed_user.email,
password: @confirmed_user.password,
remember_me: 1
}
}
assert_not_nil current_user
assert_not_nil cookies[:remember_token]
end

remember_me_cookie = cookies.get_cookie("remember_token")

assert remember_me_cookie.http_only?
assert remember_me_cookie.secure?
assert_equal "Strict", remember_me_cookie.to_h["SameSite"]

@stevepolitodesign stevepolitodesign removed their assignment Mar 17, 2023
mdchaney added a commit to mdchaney/rails-authentication-from-scratch that referenced this issue Jun 12, 2024
Asserts cookie is http_only, secure, and same-site is "strict".
Closes stevepolitodesign#87.
mdchaney added a commit to mdchaney/rails-authentication-from-scratch that referenced this issue Jun 14, 2024
1. Set to "secure" in production
2. Set to HttpOnly
3. SameSite set to strict.

Closes stevepolitodesign#87.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant