Skip to content

Add optional HMAC signing of the auto-login cookie value - #126

Open
vjik wants to merge 9 commits into
masterfrom
cookie-readme
Open

Add optional HMAC signing of the auto-login cookie value#126
vjik wants to merge 9 commits into
masterfrom
cookie-readme

Conversation

@vjik

@vjik vjik commented Aug 16, 2026

Copy link
Copy Markdown
Member
Q A
Is bugfix?
New feature?
Breaks BC?
Fix #125

@vjik vjik changed the title Cookie readme Add note about cookie protection Aug 16, 2026
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.67%. Comparing base (53f13da) to head (b3b3b77).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #126      +/-   ##
============================================
+ Coverage     99.65%   99.67%   +0.02%     
- Complexity      110      122      +12     
============================================
  Files            15       15              
  Lines           290      311      +21     
============================================
+ Hits            289      310      +21     
  Misses            1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vjik
vjik requested a review from a team August 16, 2026 06:27
@vjik vjik added the status:code review The pull request needs review. label Aug 16, 2026

@samdark samdark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need some docs fixes.

Comment thread README.md Outdated
validate it and login the user automatically.

> [!note]
> The auto-login cookie value isn't protected against tampering by this package. This isn't only about

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't it already mentioned in "Preventing the substitution of cookies" which mentions order which is critical for it to work?

*
* The auto-login cookie value isn't protected against tampering by this package. This isn't only about
* the end user editing their own cookie — anyone who steals the cookie value can modify it too, e.g. to
* remove its expiration. Use {@see CookieMiddleware} to sign or encrypt it if you want to prevent that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's better to refer to README since order of middlware is critical for it to work proeprly.

@vjik vjik changed the title Add note about cookie protection Add optional HMAC signing of the auto-login cookie value Sep 1, 2026
@vjik
vjik requested review from samdark and a balanced review from Copilot September 1, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread config/params.php
'cookieLogin' => [
'forceAddCookie' => false,
'duration' => 'P5D', // 5 days, see format on https://www.php.net/manual/dateinterval.construct.php
'signatureKey' => null, // secret key to sign the auto-login cookie value; keep `null` to store it unsigned
Comment thread src/Login/Cookie/CookieLogin.php Outdated
Comment thread tests/Login/Cookie/CookieLoginMiddlewareTest.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CookieLogin: client can bypass remember-me TTL by setting expires=0

3 participants