Skip to content

Commit bfc31ba

Browse files
author
Steve Riesenberg
committed
Polish Username/Password Authentication page
Issue gh-11926 (cherry picked from commit 781d575)
1 parent ad2bea3 commit bfc31ba

File tree

1 file changed

+30
-24
lines changed
  • docs/modules/ROOT/pages/servlet/authentication/passwords

1 file changed

+30
-24
lines changed

docs/modules/ROOT/pages/servlet/authentication/passwords/index.adoc

+30-24
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ class SecurityConfig {
7777
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
7878
http {
7979
authorizeHttpRequests {
80-
authorize(anyRequest, authenticated)
80+
authorize(anyRequest, authenticated)
8181
}
8282
formLogin { }
8383
httpBasic { }
84-
}
84+
}
8585
8686
return http.build()
8787
}
@@ -105,14 +105,14 @@ The preceding configuration automatically registers an xref:servlet/authenticati
105105

106106
To learn more about username/password authentication, consider the following use cases:
107107

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`>>
110108
* I want to xref:servlet/authentication/passwords/form.adoc[learn how Form Login works]
111109
* 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]
113111
* I want to xref:servlet/authentication/passwords/in-memory.adoc[manage users in memory]
114112
* I want to xref:servlet/authentication/passwords/jdbc.adoc[manage users in a database]
115113
* 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`>>
116116

117117
[[publish-authentication-manager-bean]]
118118
== Publish an `AuthenticationManager` bean
@@ -199,14 +199,16 @@ XML::
199199
</user-service>
200200
201201
<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"/>
203203
</http>
204204
----
205205
206206
Kotlin::
207207
+
208208
[source,kotlin,role="secondary"]
209209
----
210+
import org.springframework.security.config.annotation.web.invoke
211+
210212
@Configuration
211213
@EnableWebSecurity
212214
class SecurityConfig {
@@ -215,6 +217,7 @@ class SecurityConfig {
215217
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
216218
http {
217219
authorizeHttpRequests {
220+
authorize("/login", permitAll)
218221
authorize(anyRequest, authenticated)
219222
}
220223
}
@@ -410,22 +413,25 @@ XML::
410413
</user-service>
411414
412415
<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"/>
414417
</http>
415418
----
416419
417420
Kotlin::
418421
+
419422
[source,kotlin,role="secondary"]
420423
----
424+
import org.springframework.security.config.annotation.web.invoke
425+
421426
@Configuration
422427
@EnableWebSecurity
423-
public class SecurityConfig {
428+
class SecurityConfig {
424429
425430
@Bean
426431
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
427432
http {
428433
authorizeHttpRequests {
434+
authorize("/login", permitAll)
429435
authorize(anyRequest, authenticated)
430436
}
431437
formLogin { }
@@ -483,22 +489,22 @@ Java::
483489
@EnableWebSecurity
484490
public class SecurityConfig {
485491
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+
}
491497
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+
}
497503
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+
}
502508
503509
}
504510
----
@@ -521,8 +527,8 @@ class SecurityConfig {
521527
522528
@Bean
523529
fun userDetailsService(): UserDetailsService {
524-
// Return a UserDetailsService that caches users
525-
// ...
530+
// Return a UserDetailsService that caches users
531+
// ...
526532
}
527533
528534
@Autowired

0 commit comments

Comments
 (0)