@@ -77,11 +77,11 @@ class SecurityConfig {
77
77
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
78
78
http {
79
79
authorizeHttpRequests {
80
- authorize(anyRequest, authenticated)
80
+ authorize(anyRequest, authenticated)
81
81
}
82
82
formLogin { }
83
83
httpBasic { }
84
- }
84
+ }
85
85
86
86
return http.build()
87
87
}
@@ -105,14 +105,14 @@ The preceding configuration automatically registers an xref:servlet/authenticati
105
105
106
106
To learn more about username/password authentication, consider the following use cases:
107
107
108
- * I want to <<publish-authentication-manager-bean,publish an `AuthenticationManager` bean>> for custom authentication
109
- * I want to <<customize-global-authentication-manager,customize the global `AuthenticationManager`>>
110
108
* I want to xref:servlet/authentication/passwords/form.adoc[learn how Form Login works]
111
109
* I want to xref:servlet/authentication/passwords/basic.adoc[learn how HTTP Basic authentication works]
112
- * I want to xref:servlet/authentication/passwords/basic .adoc[learn how `DaoAuthenticationProvider` works]
110
+ * I want to xref:servlet/authentication/passwords/dao-authentication-provider .adoc[learn how `DaoAuthenticationProvider` works]
113
111
* I want to xref:servlet/authentication/passwords/in-memory.adoc[manage users in memory]
114
112
* I want to xref:servlet/authentication/passwords/jdbc.adoc[manage users in a database]
115
113
* I want to xref:servlet/authentication/passwords/ldap.adoc#servlet-authentication-ldap-authentication[manage users in LDAP]
114
+ * I want to <<publish-authentication-manager-bean,publish an `AuthenticationManager` bean>> for custom authentication
115
+ * I want to <<customize-global-authentication-manager,customize the global `AuthenticationManager`>>
116
116
117
117
[[publish-authentication-manager-bean]]
118
118
== Publish an `AuthenticationManager` bean
@@ -199,14 +199,16 @@ XML::
199
199
</user-service>
200
200
201
201
<bean id="passwordEncoder"
202
- class="org.springframework.security.crypto.factory.PasswordEncoderFactories" factory-method="createDelegatingPasswordEncoder"/>
202
+ class="org.springframework.security.crypto.factory.PasswordEncoderFactories" factory-method="createDelegatingPasswordEncoder"/>
203
203
</http>
204
204
----
205
205
206
206
Kotlin::
207
207
+
208
208
[source,kotlin,role="secondary"]
209
209
----
210
+ import org.springframework.security.config.annotation.web.invoke
211
+
210
212
@Configuration
211
213
@EnableWebSecurity
212
214
class SecurityConfig {
@@ -215,6 +217,7 @@ class SecurityConfig {
215
217
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
216
218
http {
217
219
authorizeHttpRequests {
220
+ authorize("/login", permitAll)
218
221
authorize(anyRequest, authenticated)
219
222
}
220
223
}
@@ -410,22 +413,25 @@ XML::
410
413
</user-service>
411
414
412
415
<bean id="passwordEncoder"
413
- class="org.springframework.security.crypto.factory.PasswordEncoderFactories" factory-method="createDelegatingPasswordEncoder"/>
416
+ class="org.springframework.security.crypto.factory.PasswordEncoderFactories" factory-method="createDelegatingPasswordEncoder"/>
414
417
</http>
415
418
----
416
419
417
420
Kotlin::
418
421
+
419
422
[source,kotlin,role="secondary"]
420
423
----
424
+ import org.springframework.security.config.annotation.web.invoke
425
+
421
426
@Configuration
422
427
@EnableWebSecurity
423
- public class SecurityConfig {
428
+ class SecurityConfig {
424
429
425
430
@Bean
426
431
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
427
432
http {
428
433
authorizeHttpRequests {
434
+ authorize("/login", permitAll)
429
435
authorize(anyRequest, authenticated)
430
436
}
431
437
formLogin { }
@@ -483,22 +489,22 @@ Java::
483
489
@EnableWebSecurity
484
490
public class SecurityConfig {
485
491
486
- @Bean
487
- public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
488
- // ...
489
- return http.build();
490
- }
492
+ @Bean
493
+ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
494
+ // ...
495
+ return http.build();
496
+ }
491
497
492
- @Bean
493
- public UserDetailsService userDetailsService() {
494
- // Return a UserDetailsService that caches users
495
- // ...
496
- }
498
+ @Bean
499
+ public UserDetailsService userDetailsService() {
500
+ // Return a UserDetailsService that caches users
501
+ // ...
502
+ }
497
503
498
- @Autowired
499
- public void configure(AuthenticationManagerBuilder builder) {
500
- builder.eraseCredentials(false);
501
- }
504
+ @Autowired
505
+ public void configure(AuthenticationManagerBuilder builder) {
506
+ builder.eraseCredentials(false);
507
+ }
502
508
503
509
}
504
510
----
@@ -521,8 +527,8 @@ class SecurityConfig {
521
527
522
528
@Bean
523
529
fun userDetailsService(): UserDetailsService {
524
- // Return a UserDetailsService that caches users
525
- // ...
530
+ // Return a UserDetailsService that caches users
531
+ // ...
526
532
}
527
533
528
534
@Autowired
0 commit comments