Fix broken Swagger path due to incomplete Spring Security configuration (#23)#25
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe PR updates Spring Security configuration to resolve Swagger access issues by permitting unauthenticated requests to Swagger UI and OpenAPI documentation endpoints, while also simplifying the method signature by removing the throws declaration. ChangesSpring Security Configuration for Swagger Access
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@backend/smartjam-api/src/main/java/com/smartjam/smartjamapi/config/SecurityConfig.java`:
- Around line 26-27: The current SecurityConfig change permits "/swagger-ui/**",
"/v3/api-docs/**", and "/api.yaml" via
authorizeHttpRequests(requestMatchers(...)) which exposes API docs in
production; update the configuration to restrict Swagger in prod by introducing
environment-specific SecurityFilterChain beans (e.g., devSecurityFilterChain and
prodSecurityFilterChain) and annotate with `@Profile`("!prod") and
`@Profile`("prod") respectively, keeping the existing jwtAuthFilter and session
policy but only permitting Swagger endpoints in non-production and removing them
from the permitAll requestMatchers in the production chain (or require
authentication) so that SecurityConfig no longer publicly exposes Swagger in
prod.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 55f6b608-6757-4061-a41b-e0b42c8e321b
📒 Files selected for processing (1)
backend/smartjam-api/src/main/java/com/smartjam/smartjamapi/config/SecurityConfig.java
What was fixed
Closes #23