5.0.1: case-insensitive trustedHosts + PR review nits#320
Conversation
… nits Fold in PR feedback ahead of the 5.0.1 release: - AppUrlResolver: match user.security.trustedHosts case-insensitively (RFC 4343). A mixed-case configured entry or X-Forwarded-Host (e.g. App.Example.Com) previously failed to match app.example.com, causing the CWE-640 path to ignore a legitimately trusted forwarded host and fall back to the container server name. Adds a test. - Role.java: condense the multi-line EAGER rationale comment to one line (CLAUDE.md style). - UserRepositoryEntityGraphTest: fix stale class Javadoc (Role.privileges is EAGER again) and name the collection in the plain-finder test comment. - Docs: soften 'single query' to 'single round trip (bounded, typically one query)' in UserRepository Javadoc, MIGRATION, and the 5.0.1 CHANGELOG entry — the EntityGraph test tolerates a small statement bound across JPA providers. - CHANGELOG: record the trustedHosts case-insensitivity fix under [5.0.1] Fixed.
There was a problem hiding this comment.
Pull request overview
Updates the security email app-URL resolution to treat user.security.trustedHosts matching as case-insensitive (so trusted forwarded hosts are reliably honored), and folds in several documentation/comment nits ahead of the 5.0.1 release.
Changes:
- Normalize trusted-host allow-list entries and forwarded-host comparisons to lower case (RFC 4343) and add a regression test.
- Refine repository/entity documentation around LAZY/EAGER behavior and clarify the “single round trip” entity-graph semantics.
- Update 5.0.1 release notes / migration guidance to match the above.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/digitalsanctuary/spring/user/util/AppUrlResolver.java | Normalizes trusted-host matching to be case-insensitive while preserving existing URL construction behavior. |
| src/test/java/com/digitalsanctuary/spring/user/util/AppUrlResolverTest.java | Adds a case-insensitive allow-list/forwarded-host regression test. |
| src/main/java/com/digitalsanctuary/spring/user/persistence/repository/UserRepository.java | Clarifies Javadoc to “single round trip (bounded, typically single query)”. |
| src/test/java/com/digitalsanctuary/spring/user/persistence/repository/UserRepositoryEntityGraphTest.java | Updates class/test comments to reflect Role.privileges being EAGER again and clarifies LAZY target (User.roles). |
| src/main/java/com/digitalsanctuary/spring/user/persistence/model/Role.java | Condenses EAGER rationale comment for Role.privileges. |
| MIGRATION.md | Updates migration text to “single round trip” wording and keeps 5.0.1 privilege-fetch note accurate. |
| CHANGELOG.md | Updates 5.0.1 notes: “single round trip” wording and adds the trustedHosts case-insensitivity fix entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review — PR #320: 5.0.1: case-insensitive trustedHosts + PR review nits
OverviewThis PR bundles one substantive bug fix with several documentation/comment nits carried over from the #318/#319 review cycle. The scope is well-controlled and the changes are tightly focused. Bug Fix:
|
| Area | Assessment |
|---|---|
| Bug fix correctness | ✅ Correct — Locale.ROOT, right normalisation order, case preserved in output |
| Test coverage | ✅ New test covers mixed-case allow-list and mixed-case header |
| Javadoc accuracy | ✅ "single round trip" is more honest than "single query" |
| Comment style | ✅ Condensed to CLAUDE.md standard |
| Test naming convention | should…When… pattern (pre-existing issue in the file) |
Clean PR — no blocking issues.
Folds in the still-open feedback from the #318 / #319 reviews ahead of the 5.0.1 release.
Fixes
trustedHostscase-insensitive match (AppUrlResolver) — the one substantive open bug. A mixed-case configured entry orX-Forwarded-Host(e.g.App.Example.Com) previously failed to matchapp.example.com, so the CWE-640 path ignored a legitimately trusted forwarded host and fell back to the container server name. Normalises both sides to lower case (RFC 4343) + adds a test.Review nits
Role.java: condense the multi-line EAGER rationale to one line (CLAUDE.md style).UserRepositoryEntityGraphTest: fix stale class Javadoc (Role.privilegesis EAGER again) and name the collection in the plain-finder test comment.UserRepositoryJavadoc,MIGRATION.md, and the 5.0.1CHANGELOGentry — the EntityGraph test tolerates a small statement bound across JPA providers.Already-resolved (verified, no change needed)
Passwordless message consistency,
serialVersionUIDon all event classes, trailing-slash strip, X-Forwarded comma handling, null/blank privilege guard, and log sanitization (sanitizeForLog) were all already fixed in #318. The CodeQL log-injection alerts are stale (sites are sanitized) and can be dismissed.Test Plan
./gradlew clean testgreen; newmatchesAllowListedForwardedHostCaseInsensitivelypasses.