bugfix: register dev auth filter inside Spring Security#208
Conversation
filter chain DevSecurityConfig's X-Dev-User filter was auto-registered as a servlet filter, causing SecurityContextHolderFilter to reset the SecurityContext before auth could be checked. Moved it inside the security chain via SecurityConfig. Also reverted incorrect ObjectMapper import in controller tests to tools.jackson.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 25 minutes and 51 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe changes introduce selective registration of a development authentication filter into the Spring Security filter chain. The Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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 `@src/main/java/org/example/vet1177/config/DevSecurityConfig.java`:
- Around line 70-72: The devAuthFilterRegistration method is injecting a
OncePerRequestFilter ambiguously (there are multiple OncePerRequestFilter beans
such as JwtAuthenticationFilter); fix by adding `@Qualifier`("devAuthFilter") to
the method parameter so Spring injects the specific "devAuthFilter" bean —
update the parameter in devAuthFilterRegistration to accept `@Lazy`
`@Qualifier`("devAuthFilter") OncePerRequestFilter devAuthFilter to disambiguate
injection.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 32e1daa9-2c6a-49b1-8693-96a90317e3f2
📒 Files selected for processing (2)
src/main/java/org/example/vet1177/config/DevSecurityConfig.javasrc/main/java/org/example/vet1177/security/SecurityConfig.java
Entity used description/created_at but schema defines details/performed_at. Also added missing entity_type field which is NOT NULL in the schema, causing a constraint violation on every medical record creation.
of 500 The generic Exception handler was catching Spring's AccessDeniedException before it could be mapped to 403, causing @PreAuthorize failures to return 500.
injection in DevSecurityConfig
filter chain
DevSecurityConfig's X-Dev-User filter was auto-registered
as a servlet filter,
causing SecurityContextHolderFilter to reset the
SecurityContext before auth
could be checked. Moved it inside the security chain via
SecurityConfig.
Also reverted incorrect ObjectMapper import in controller
tests to tools.jackson.
Summary by CodeRabbit