In Spring Security 6.0, many methods and classes have been deprecated. Let's look at the main deprecated elements:
Deprecated Methods
authorizeHttpRequests()
- UseauthorizeHttpRequests(Customizer)
insteadantMatchers()
- UserequestMatchers()
which supports URLs, regex, and path patternsanonymous()
- Useanonymous(Customizer)
formLogin()
- UseformLogin(Customizer)
httpBasic()
- UsehttpBasic(Customizer)
Deprecated Classes
WebSecurityConfigurerAdapter
- Use component-based configuration insteadClasses related to method security:
@EnableGlobalMethodSecurity
- Use@EnableMethodSecurity
MethodSecurityMetadataSourceBeanDefinitionParser
Annotation Interfaces
@EnableGlobalMethodSecurity
- Use@EnableMethodSecurity
instead
Deprecated Constructors
Some constructors have been deprecated in favor of new ones.
Deprecated Fields
Some fields have been deprecated, for example:
AUTHORIZATION_TYPE_PASSWORD
inAuthorizationGrantType
Reasons for Deprecation
The main reasons for deprecation are:
Providing a more flexible and extensible API
Moving to a component-based configuration instead of extending base classes
Improving security and removing insecure options