spring-projects / spring-projects/spring-security
Align Return Types of no-arg and Customizer arg Configuration Methods
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
It is a common way to configure Spring Security like this:
http.formLogin();
http.httpBasic();
Where each configuration is in its own line, this is quite a reasonable alternative and there are many users who prefer this way to chaining methods.
With the deprecation of .and() and the non-lambda methods (see #12629), and, therefore, the removal in 7.0, users will be forced to use:
http.formLogin(Customizer.withDefaults());
http.httpBasic(Customizer.withDefaults());
The above configuration does not give any advantage over the former. We should consider replacing the deprecated methods with a variant that returns the root builder object, for example, HttpSecurity.
public HttpSecurity httpBasic() {
// ...
}
Some methods, like oauth2ResourceServer, maybe should not return HttpSecurity since it doesn't make sense to configure it without the additional .jwt() or .opaqueToken() methods.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the no-argument and Customizer-argument configuration methods described in this issue, along with the deprecation context in #12629. Determine which methods should return HttpSecurity and which, such as oauth2ResourceServer, should retain a specialized return type; done means the return types are consistent without losing supported configuration paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- developer-experience, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100