spring-projects / spring-projects/spring-security

Docs: WebFlux security example uses deprecated builder-style API Expected Behavior

Open
#17,704 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: enhancement
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Expected Behavior

The documentation for ServerHttpSecurity should showcase the modern, non-deprecated Lambda DSL style for configuring SecurityWebFilterChain. This is the current best practice and provides a future-proof example for users.

The code example should look like this:

import org.springframework.security.config.Customizer;

// ...

    @Bean
    public SecurityWebFilterChain securityFilterChain(ServerHttpSecurity http) {
        http
            .authorizeExchange(authorize -> authorize.anyExchange().authenticated())
            .httpBasic(Customizer.withDefaults())
            .formLogin(Customizer.withDefaults());
        return http.build();
    }
Current Behavior

The documentation currently displays an example using the older, builder-style configuration. This uses several methods that were formally deprecated in Spring Security 6.1, including .authorizeExchange(), .and(), .httpBasic(), and .formLogin().

This is the code currently shown in the documentation:

@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
    http
        .authorizeExchange()
          .anyExchange().authenticated()
        .and()
          .httpBasic().and()
          .formLogin();
        return http.build();
}
Context

As a developer learning how to configure WebFlux security, I used the official documentation as my primary guide. When I implemented the provided example, my IDE immediately flagged all the chained methods as deprecated.

This can be confusing for new users, as it creates uncertainty about whether they are following the correct and most current best practices. The only workaround is to have prior knowledge of the Lambda DSL and to know that the documentation is out of sync with the API's current state.

Updating this example would provide a clearer, more modern learning path for developers and ensure the documentation accurately reflects the recommended approach for configuring Spring Security.

I am happy to submit a pull request to update the relevant documentation file.

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

Locate the WebFlux security documentation example for ServerHttpSecurity and SecurityWebFilterChain, then compare it with the modern Lambda DSL example provided in the issue. Replace the deprecated builder-style snippet with the requested configuration and verify that the documentation shows the current non-deprecated API.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
documentation, security
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.