Skip to content

Fix failing Cypress E2E suite: login redirect (cookie_secure) - #3757

Merged
bobvandevijver merged 3 commits into
bolt:6.1from
Vondry:fix/login-redirect-cookie-secure
Aug 3, 2026
Merged

Fix failing Cypress E2E suite: login redirect (cookie_secure)#3757
bobvandevijver merged 3 commits into
bolt:6.1from
Vondry:fix/login-redirect-cookie-secure

Conversation

@Vondry

@Vondry Vondry commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Fix login redirect timeouts (cookie_secure)

Problem

Every login-based test failed with:

expected http://127.0.0.1:8088/bolt/ but got http://127.0.0.1:8088/

Authentication succeeded, but users were redirected to the homepage instead of the Bolt dashboard, causing the /bolt/ assertion to time out.

Root cause

The regression resulted from the interaction of two independent commits:

Commit Change
fbd0ed3aResolve framework configuration deprecations Set cookie_secure: true (previously omitted, using Symfony's default of false).
db37ed5dBlock open redirect on login endpoint Replaced new RedirectResponse(...) with HttpUtils::createRedirectResponse(...) for post-login redirects.

HttpUtils::createRedirectResponse() validates redirect targets against a regular expression generated from the session cookie configuration (AddSessionDomainConstraintPass). With cookie_secure: true, Symfony generates an HTTPS-only pattern ({^https://<host>$}i).

The failing flow was:

  1. The Cypress login helper visits /bolt, so Symfony stores the target path as http://127.0.0.1:8088/bolt.
  2. CI runs the application over plain HTTP (symfony server:start --no-tls).
  3. After authentication, the saved http://... URL fails the HTTPS-only validation, so createRedirectResponse() falls back to /.
  4. Authentication succeeds, but the user lands on the homepage, causing the /bolt/ assertion to time out.

This was broader than a test-only issue. Any Bolt installation running over plain HTTP would also have broken login sessions because browsers discard Secure cookies on HTTP.

The fix

cookie_secure: 'auto' is Symfony's recommended value for this deprecation. It applies the Secure flag only when the current request uses HTTPS.

As a result:

  • On HTTP requests, redirect validation accepts both http:// and https:// same-host URLs, restoring the post-login redirect to /bolt/.
  • On HTTPS requests, validation remains HTTPS-only, preserving protection against open redirects and scheme downgrades.

Security impact: None for correctly configured HTTPS deployments. On HTTPS, auto behaves identically to true. On HTTP, true never provided meaningful protection because browsers discard Secure cookies anyway.

@Vondry
Vondry force-pushed the fix/login-redirect-cookie-secure branch from 1f46cc3 to 46cb956 Compare July 23, 2026 13:45
Comment thread config/packages/framework.yaml
Comment thread .github/workflows/cypress_tests.yaml Outdated
@Vondry
Vondry force-pushed the fix/login-redirect-cookie-secure branch from 46cb956 to eefed87 Compare August 3, 2026 13:17
@Vondry
Vondry requested a review from bobvandevijver August 3, 2026 13:19
Vondry added 2 commits August 3, 2026 17:45
Setting cookie_secure: true forces the session-domain constraint
(used by HttpUtils::createRedirectResponse since the open-redirect
fix) to require HTTPS targets. On plain-HTTP installs the saved
target path is an http:// URL, so the post-login redirect fails the
https-only regexp and falls back to '/', landing users on the
homepage instead of /bolt/. This broke every Cypress login test.

'auto' sets the Secure flag only on HTTPS requests (Symfony's
recommended default), restoring same-host HTTP redirects while
keeping open-redirect protection intact on HTTPS.
@Vondry
Vondry force-pushed the fix/login-redirect-cookie-secure branch from eefed87 to 64df8da Compare August 3, 2026 15:46
m_2025-12-01-framework.yaml added `cookie_secure: true` to existing
installs, so upgraded sites keep the value that breaks the post-login
redirect on plain HTTP. Overwrite it with 'auto' to match the shipped
config.
@bobvandevijver bobvandevijver changed the title Fix failing Cypress E2E suite: login redirect (cookie_secure) and CI PHP 8.4 bump Fix failing Cypress E2E suite: login redirect (cookie_secure) Aug 3, 2026
@bobvandevijver
bobvandevijver merged commit 8727bca into bolt:6.1 Aug 3, 2026
34 of 35 checks passed
@bobvandevijver

bobvandevijver commented Aug 3, 2026

Copy link
Copy Markdown
Member

Note that Cypress is still failing, but that seems to be an issue with the API generator and the collection types.

"Illuminate\Support\TKey" is not a valid array key type.

But that is something for a different PR -> #3774

@bobvandevijver bobvandevijver added this to the Bolt 6.1 milestone Aug 4, 2026
@bobvandevijver bobvandevijver added 🐛 tag: bug This is a bug. 🐛 tag: bug fix and removed 🐛 tag: bug This is a bug. labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants