fix(security): enforce validation on request bodies and tighten JWT issuer checks#175
Conversation
📝 WalkthroughWalkthroughSix files across security and input validation domains were modified. Changes include JWT issuer claim validation and token expiration reduction, sensitive HTTP header redaction in request logging, stricter frame-option security headers, and systematic addition of validation annotations to multiple controller request body parameters. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@booklore-api/src/main/java/org/booklore/config/security/JwtUtils.java`:
- Around line 79-85: The current JwtUtils issuer check silently allows
issuer-less tokens indefinitely; change it to read a configurable cutoff (e.g.,
env/config property like jwt.issuerEnforceDate or JWT_ISSUER_ENFORCE_DATE) and
enforce the issuer after that date: keep the existing graceful behavior (allow
null issuer) only if now is before the configured cutoff, but once now >= cutoff
require claims.getIssuer() to equal "booklore" and throw JwtException otherwise;
update the issuer logic in JwtUtils (the block using claims.getIssuer()) to
parse the configured cutoff (with a safe default set to 2026-04-24) and branch
on current date so the grace period is time-limited and configurable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fbe75c27-d23c-4ba2-b6ea-7c9ce8ec1277
📒 Files selected for processing (6)
booklore-api/src/main/java/org/booklore/config/LoggingFilter.javabooklore-api/src/main/java/org/booklore/config/security/JwtUtils.javabooklore-api/src/main/java/org/booklore/config/security/SecurityConfig.javabooklore-api/src/main/java/org/booklore/controller/BookdropFileController.javabooklore-api/src/main/java/org/booklore/controller/MetadataController.javabooklore-api/src/main/java/org/booklore/controller/OidcGroupMappingController.java
|
@balazs-szucs can we add some tests here? |
this is boilerplate. |
Description
Linked Issue: Fixes #
Changes
JWT Hardening (
JwtUtils.java)iss: "booklore"claimbut allows legacy tokens with no issuer claim to pass through
.requireIssuer("booklore")once all legacy tokens have naturally expired
Security Headers (
SecurityConfig.java)X-Frame-Options: DENYto prevent clickjackingInput Validation (Controllers)
@Valid/@Validatedto request bodies across:BookdropFileControllerdiscard files, finalize importMetadataControllerupdate, bulk edit, toggle locks, ISBN lookupOidcGroupMappingControllercreate, updatehad Bean Validation constraints
Logging (
LoggingFilter.java)Authorization,Cookie,Set-Cookie,X-API-Key,X-Forwarded-Access-Token) are now redacted in dev profile request loggingSummary by CodeRabbit
Security & Hardening
Data Validation