Skip to content

Commit 67544f3

Browse files
Steve Riesenbergsjohnr
Steve Riesenberg
authored andcommitted
Remove references to WebSecurityConfigurerAdapter
* AbstractAuthenticationFilterConfigurer * DefaultLoginPageConfigurer * EnableGlobalAuthentication * FormLoginConfigurer * HeadersConfigurer * HttpSecurity * OpenIDLoginConfigurer * RememberMeConfigurer * WebSecurity * WebSecurityConfiguration * WebSecurityConfigurer * X509Configurer Closes gh-11288
1 parent 05725af commit 67544f3

File tree

12 files changed

+811
-444
lines changed

12 files changed

+811
-444
lines changed

config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/EnableGlobalAuthentication.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,10 +39,19 @@
3939
* @EnableGlobalAuthentication
4040
* public class MyGlobalAuthenticationConfiguration {
4141
*
42-
* @Autowired
43-
* public void configureGlobal(AuthenticationManagerBuilder auth) {
44-
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER")
45-
* .and().withUser("admin").password("password").roles("USER", "ADMIN");
42+
* @Bean
43+
* public UserDetailsService userDetailsService() {
44+
* UserDetails user = User.withDefaultPasswordEncoder()
45+
* .username("user")
46+
* .password("password")
47+
* .roles("USER")
48+
* .build();
49+
* UserDetails admin = User.withDefaultPasswordEncoder()
50+
* .username("admin")
51+
* .password("password")
52+
* .roles("ADMIN", "USER")
53+
* .build();
54+
* return new InMemoryUserDetailsManager(user, admin);
4655
* }
4756
* }
4857
* </pre>
@@ -54,15 +63,24 @@
5463
* <pre class="code">
5564
* &#064;Configuration
5665
* &#064;EnableWebSecurity
57-
* public class MyWebSecurityConfiguration extends WebSecurityConfigurerAdapter {
66+
* public class MyWebSecurityConfiguration {
5867
*
59-
* &#064;Autowired
60-
* public void configureGlobal(AuthenticationManagerBuilder auth) {
61-
* auth.inMemoryAuthentication().withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;)
62-
* .and().withUser(&quot;admin&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;, &quot;ADMIN&quot;);
68+
* &#064;Bean
69+
* public UserDetailsService userDetailsService() {
70+
* UserDetails user = User.withDefaultPasswordEncoder()
71+
* .username(&quot;user&quot;)
72+
* .password(&quot;password&quot;)
73+
* .roles(&quot;USER&quot;)
74+
* .build();
75+
* UserDetails admin = User.withDefaultPasswordEncoder()
76+
* .username(&quot;admin&quot;)
77+
* .password(&quot;password&quot;)
78+
* .roles(&quot;ADMIN&quot;, &quot;USER&quot;)
79+
* .build();
80+
* return new InMemoryUserDetailsManager(user, admin);
6381
* }
6482
*
65-
* // Possibly overridden methods ...
83+
* // Possibly more bean methods ...
6684
* }
6785
* </pre>
6886
*

config/src/main/java/org/springframework/security/config/annotation/web/WebSecurityConfigurer.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,19 +23,16 @@
2323
import org.springframework.security.config.annotation.SecurityConfigurer;
2424
import org.springframework.security.config.annotation.web.builders.WebSecurity;
2525
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
26-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
2726
import org.springframework.security.web.SecurityFilterChain;
2827

2928
/**
3029
* Allows customization to the {@link WebSecurity}. In most instances users will use
31-
* {@link EnableWebSecurity} and either create a {@link Configuration} that extends
32-
* {@link WebSecurityConfigurerAdapter} or expose a {@link SecurityFilterChain} bean. Both
33-
* will automatically be applied to the {@link WebSecurity} by the
34-
* {@link EnableWebSecurity} annotation.
30+
* {@link EnableWebSecurity} and create a {@link Configuration} that exposes a
31+
* {@link SecurityFilterChain} bean. This will automatically be applied to the
32+
* {@link WebSecurity} by the {@link EnableWebSecurity} annotation.
3533
*
3634
* @author Rob Winch
3735
* @since 3.2
38-
* @see WebSecurityConfigurerAdapter
3936
* @see SecurityFilterChain
4037
*/
4138
public interface WebSecurityConfigurer<T extends SecurityBuilder<Filter>> extends SecurityConfigurer<Filter, T> {

0 commit comments

Comments
 (0)