Skip to content

Add remember-me support to the reference login form (#79) - #80

Merged
devondragon merged 5 commits into
mainfrom
feature/79-remember-me-checkbox-login-form
Aug 13, 2026
Merged

Add remember-me support to the reference login form (#79)#80
devondragon merged 5 commits into
mainfrom
feature/79-remember-me-checkbox-login-form

Conversation

@devondragon

Copy link
Copy Markdown
Owner

Summary

Makes remember-me reachable from the documented login path, now that ds-spring-user-framework 5.2.0 completes the feature (devondragon/SpringUserFramework#351).

Changes

  • build.gradle — adopt ds-spring-user-framework 5.2.0
  • login.html — remember-me checkbox posting the framework-default remember-me parameter; label via new label.form.login-remember message key
  • application.yml — remember-me enabled; signing key from REMEMBER_ME_KEY env var with a demo-only fallback so a fresh clone works
  • application-prd.yml — fail-fast ${REMEMBER_ME_KEY} (no default) and useSecureCookie: true, mirroring the session-cookie hardening, so the ~14-day token is never issued over plain HTTP behind a TLS-terminating proxy
  • Playwright — LoginPage.checkRememberMe() + 4-test spec: persistent cookie issued when checked (httpOnly, future expiry), no cookie when unchecked, auto-login after session cookie removal, fresh-login baseline

Testing

  • ./gradlew test passes with 5.2.0 (artifact resolved from Maven Central)
  • remember-me.spec.ts passes on Chromium, Firefox, Mobile Chrome (WebKit fails locally, but pre-existing: login.spec.ts fails identically on WebKit in this environment)
  • Code review (ticket-grounded, multi-agent): 0 critical; the 1 high (missing Secure flag behind proxy) and 1 medium (no cookie-persistence assertion) findings are fixed in this PR

Closes #79

Brings in completed remember-me support (devondragon/SpringUserFramework#351):
configurable token validity, parameter/cookie names, secure-cookie flag, and
an optional persistent token store with server-side revocation.

Refs #79
…r-me

Add the remember-me checkbox to the reference login form so the framework's
remember-me support is reachable from the documented login path. The
parameter name matches the framework default (remember-me); without it
AbstractRememberMeServices never issues a cookie.

Enable user.security.rememberMe in the demo config with an env-var-backed
signing key (demo-only default so a fresh clone works out of the box). The
prd profile requires REMEMBER_ME_KEY with no fallback (fail-fast) and forces
useSecureCookie so the ~14-day token is never sent over plain HTTP behind a
TLS-terminating proxy.

Refs #79
Extend LoginPage with a remember-me checkbox locator and add a spec
covering: persistent cookie issued when checked (httpOnly, future expiry),
no cookie when unchecked, auto-login after the session cookie is dropped,
and the fresh-login baseline without remember-me.

Refs #79
Copilot AI lite review requested due to automatic review settings August 12, 2026 15:00
@devondragon devondragon self-assigned this Aug 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds end-to-end “remember-me” support to the demo app’s canonical login flow, wiring the framework’s remember-me parameter through the reference Thymeleaf login form and validating cookie/session behavior via Playwright tests.

Changes:

  • Update the login form to post the framework-default remember-me parameter and add a new i18n label key.
  • Enable/configure remember-me in application.yml with production hardening overrides in application-prd.yml.
  • Add Playwright page-object support + a new spec covering cookie issuance and re-authentication behavior.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
build.gradle Bumps ds-spring-user-framework to 5.2.0 to pick up framework-side remember-me support.
src/main/resources/templates/user/login.html Adds a remember-me checkbox posting remember-me.
src/main/resources/messages/messages.properties Adds label.form.login-remember i18n message key.
src/main/resources/application.yml Enables remember-me and configures signing key via env var with a demo fallback.
src/main/resources/application-prd.yml Removes default key (fail-fast) and forces Secure on remember-me cookie in prod.
playwright/src/pages/LoginPage.ts Adds a locator + helper for checking the remember-me checkbox.
playwright/tests/auth/remember-me.spec.ts New E2E coverage for remember-me cookie issuance and session-expiry relogin behavior.
Suppressed comments (1)

playwright/tests/auth/remember-me.spec.ts:131

  • BrowserContext.clearCookies() in Playwright does not support filtering by cookie name (e.g. { name: 'JSESSIONID' }). This call will fail at runtime and prevent the baseline (no remember-me) test from running.

If you only want to remove the session cookie, snapshot cookies, clear all, then re-add everything except JSESSIONID (or clear all cookies if preserving others isn't important here).

      await page.context().clearCookies({ name: 'JSESSIONID' });

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main/resources/application.yml Outdated
Comment on lines +145 to +148
# Secret used to sign remember-me tokens. The default below exists only so the demo works out of the box;
# in production set REMEMBER_ME_KEY (or override this property) to a long random value from your secret
# manager and keep it stable across restarts/instances.
key: ${REMEMBER_ME_KEY:local-demo-only-remember-me-key}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 65247f7 — the fallback is now ${REMEMBER_ME_KEY:${random.uuid}}, random per start, so no deployment ever runs on a publicly-known key. Cookies don't survive restarts unless REMEMBER_ME_KEY is set; the prd profile still requires it with no fallback (fail-fast).

Comment on lines +102 to +104
// Drop the server session cookie, simulating an expired/closed session.
// The remember-me cookie survives and should re-authenticate the request.
await page.context().clearCookies({ name: 'JSESSIONID' });

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Playwright has supported filtering in BrowserContext.clearCookies() since v1.43 (this repo uses ^1.58) — see https://playwright.dev/docs/api/class-browsercontext#browser-context-clear-cookies. The test passes locally and in this PR's Playwright E2E CI job, which exercises exactly this call.

A fixed fallback means any deployment that skips the prd profile and never
sets REMEMBER_ME_KEY signs tokens with a publicly-known constant. A random
per-start default keeps the demo working out of the box without that
footgun; cookies just don't survive restarts unless the env var is set.

Refs #79
@devondragon
devondragon merged commit e4a12e2 into main Aug 13, 2026
12 checks passed
@devondragon
devondragon deleted the feature/79-remember-me-checkbox-login-form branch August 13, 2026 00:16
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

Successfully merging this pull request may close these issues.

Add remember-me checkbox to the reference login form

2 participants