spring-projects / spring-projects/spring-security

SEC-2496: Provide documentation explaining how to migrate from XML configuration to JavaConfig configuration

Open
#2,689 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: docs type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Gerrit Hübbers (Migrated from SEC-2496) said:

I am in the process of migrating my application' usage of Spring Security's XML configuration to JavaConfig configuration.

From my experience, this migration is not trivial, and therefore the Spring Security documentation could have an additional section explaining how to migrate. Questions at StackOverflow seem to support my hypothesis that there is missing documentation.

In my particular case, issues I ran into during migration include:

  • with XML configuration, <remember-me .../> creates a RememberMeServices bean automatically. JavaConfig configuration requires explicit RememberMeServices and PersistentTokenRepository beans creation besides additional configuration inside configure(HttpSecurity http) with http.userDetailsService( userDetailsService() ).rememberMe().rememberMeServices( rememberMeServices() ).
  • XML configuration automatically creates a RequestCache bean. JavaConfig configuration requires explicit RequestCache bean creation besides additional configuration inside configure(HttpSecurity http).
  • Out-of-the-box, the XML configuration did not require to consider CSRF-related aspects. Out-of-the-box, JavaConfig configuration does require to consider CSRF-related aspects - e.g., when migrating, in order to have my application to work as before, in WebSecurityConfigurerAdapter.configure(HttpSecurity http), I had to explicitly disable CSRF with http.csrf().disable().
  • The springSecurityFilterChain bean seems to be created in both XML configuration and JavaConfig configuration.

For a documentation migration section, my idea is to provide a full-fledged XML configuration example, then show a 1:1 corresponding JavaConfig configuration.

Additionally, the documentation could contain subsection for each available Spring Security XML namespace element, and then show the corresponding required JavaConfig-based configuration.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing Spring Security documentation and the configuration entry points named in the issue, especially configure(HttpSecurity http) and WebSecurityConfigurerAdapter. Document an XML-to-JavaConfig migration covering remember-me, RequestCache, CSRF, and springSecurityFilterChain, then add mappings for the XML namespace elements. Done means the migration steps and corresponding configuration are clear and complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
documentation, security
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.