Skip to content

fix: migrate WebSecurityConfig from deprecated WebSecurityConfigurerAdapter to SecurityFilterChain bean for Java 17#553

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776282007-java17-api-fixes
Open

fix: migrate WebSecurityConfig from deprecated WebSecurityConfigurerAdapter to SecurityFilterChain bean for Java 17#553
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776282007-java17-api-fixes

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 15, 2026

Summary

Migrates WebSecurityConfig from the deprecated WebSecurityConfigurerAdapter pattern to the newer component-based SecurityFilterChain bean approach, as part of a Java 17 readiness review of the api layer.

Changes:

  • Remove extends WebSecurityConfigurerAdapter from WebSecurityConfig
  • Convert configure(HttpSecurity) override → @Bean SecurityFilterChain securityFilterChain(HttpSecurity)
  • Add return http.build() to produce the filter chain
  • Swap import from WebSecurityConfigurerAdapterSecurityFilterChain

Other files reviewed (no changes needed):
All 18 files under src/main/java/io/spring/api/ were reviewed for: Subject.doAs(), illegal reflection access, Nashorn usage, SecurityManager, and removed JDK APIs. The javax.validation and javax.servlet imports are provided by third-party dependencies (Hibernate Validator, embedded Tomcat) — not the JDK — so they remain correct for Spring Boot 2.6.x on Java 17.

Review & Testing Checklist for Human

  • Verify the SecurityFilterChain bean approach is compatible with the project's Spring Security 5.6.x (Spring Boot 2.6.3). The bean-based approach works in 5.6.x, but WebSecurityConfigurerAdapter wasn't formally deprecated until 5.7 — confirm this migration is desired now.
  • Confirm that calling jwtTokenFilter() directly inside securityFilterChain() still returns the Spring-managed singleton (both are @Bean methods in the same @Configuration class, so CGLIB proxying should handle this).
  • Run the full test suite (./gradlew test) to verify no regressions in authentication/authorization behavior — compileJava passed but tests were not executed in this session.

Notes

  • spotlessCheck fails on master with an IllegalAccessError from google-java-format under Java 17 due to module encapsulation (jdk.compiler does not export internals). This is a pre-existing build config issue unrelated to this change.

Link to Devin session: https://app.devin.ai/sessions/1dbb3d71e84342b79705f3640e06db06
Requested by: @shayanshafii


Open with Devin

…dapter to SecurityFilterChain bean

- Remove extends WebSecurityConfigurerAdapter (deprecated in Spring Security 5.7+)
- Replace configure(HttpSecurity) override with @bean SecurityFilterChain method
- Add http.build() return statement for the new bean-based approach
- Import SecurityFilterChain instead of WebSecurityConfigurerAdapter

This change prepares the api layer for Java 17 compatibility by removing
usage of the deprecated WebSecurityConfigurerAdapter pattern in favor of
the recommended component-based security configuration approach.

Co-Authored-By: shayan <shayan@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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.

1 participant