Merge branch '5.8.x' into 6.0.x
This commit is contained in:
commit
017e8d9eb8
|
@ -77,11 +77,11 @@ class SecurityConfig {
|
||||||
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
http {
|
http {
|
||||||
authorizeHttpRequests {
|
authorizeHttpRequests {
|
||||||
authorize(anyRequest, authenticated)
|
authorize(anyRequest, authenticated)
|
||||||
}
|
}
|
||||||
formLogin { }
|
formLogin { }
|
||||||
httpBasic { }
|
httpBasic { }
|
||||||
}
|
}
|
||||||
|
|
||||||
return http.build()
|
return http.build()
|
||||||
}
|
}
|
||||||
|
@ -105,14 +105,14 @@ The preceding configuration automatically registers an xref:servlet/authenticati
|
||||||
|
|
||||||
To learn more about username/password authentication, consider the following use cases:
|
To learn more about username/password authentication, consider the following use cases:
|
||||||
|
|
||||||
* I want to <<publish-authentication-manager-bean,publish an `AuthenticationManager` bean>> for custom authentication
|
|
||||||
* I want to <<customize-global-authentication-manager,customize the global `AuthenticationManager`>>
|
|
||||||
* I want to xref:servlet/authentication/passwords/form.adoc[learn how Form Login works]
|
* I want to xref:servlet/authentication/passwords/form.adoc[learn how Form Login works]
|
||||||
* I want to xref:servlet/authentication/passwords/basic.adoc[learn how HTTP Basic authentication works]
|
* I want to xref:servlet/authentication/passwords/basic.adoc[learn how HTTP Basic authentication works]
|
||||||
* I want to xref:servlet/authentication/passwords/basic.adoc[learn how `DaoAuthenticationProvider` works]
|
* I want to xref:servlet/authentication/passwords/dao-authentication-provider.adoc[learn how `DaoAuthenticationProvider` works]
|
||||||
* I want to xref:servlet/authentication/passwords/in-memory.adoc[manage users in memory]
|
* I want to xref:servlet/authentication/passwords/in-memory.adoc[manage users in memory]
|
||||||
* I want to xref:servlet/authentication/passwords/jdbc.adoc[manage users in a database]
|
* I want to xref:servlet/authentication/passwords/jdbc.adoc[manage users in a database]
|
||||||
* I want to xref:servlet/authentication/passwords/ldap.adoc#servlet-authentication-ldap-authentication[manage users in LDAP]
|
* I want to xref:servlet/authentication/passwords/ldap.adoc#servlet-authentication-ldap-authentication[manage users in LDAP]
|
||||||
|
* I want to <<publish-authentication-manager-bean,publish an `AuthenticationManager` bean>> for custom authentication
|
||||||
|
* I want to <<customize-global-authentication-manager,customize the global `AuthenticationManager`>>
|
||||||
|
|
||||||
[[publish-authentication-manager-bean]]
|
[[publish-authentication-manager-bean]]
|
||||||
== Publish an `AuthenticationManager` bean
|
== Publish an `AuthenticationManager` bean
|
||||||
|
@ -199,7 +199,7 @@ XML::
|
||||||
</user-service>
|
</user-service>
|
||||||
|
|
||||||
<bean id="passwordEncoder"
|
<bean id="passwordEncoder"
|
||||||
class="org.springframework.security.crypto.factory.PasswordEncoderFactories" factory-method="createDelegatingPasswordEncoder"/>
|
class="org.springframework.security.crypto.factory.PasswordEncoderFactories" factory-method="createDelegatingPasswordEncoder"/>
|
||||||
</http>
|
</http>
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -207,6 +207,8 @@ Kotlin::
|
||||||
+
|
+
|
||||||
[source,kotlin,role="secondary"]
|
[source,kotlin,role="secondary"]
|
||||||
----
|
----
|
||||||
|
import org.springframework.security.config.annotation.web.invoke
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
class SecurityConfig {
|
class SecurityConfig {
|
||||||
|
@ -215,6 +217,7 @@ class SecurityConfig {
|
||||||
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
http {
|
http {
|
||||||
authorizeHttpRequests {
|
authorizeHttpRequests {
|
||||||
|
authorize("/login", permitAll)
|
||||||
authorize(anyRequest, authenticated)
|
authorize(anyRequest, authenticated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,7 +413,7 @@ XML::
|
||||||
</user-service>
|
</user-service>
|
||||||
|
|
||||||
<bean id="passwordEncoder"
|
<bean id="passwordEncoder"
|
||||||
class="org.springframework.security.crypto.factory.PasswordEncoderFactories" factory-method="createDelegatingPasswordEncoder"/>
|
class="org.springframework.security.crypto.factory.PasswordEncoderFactories" factory-method="createDelegatingPasswordEncoder"/>
|
||||||
</http>
|
</http>
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -418,14 +421,17 @@ Kotlin::
|
||||||
+
|
+
|
||||||
[source,kotlin,role="secondary"]
|
[source,kotlin,role="secondary"]
|
||||||
----
|
----
|
||||||
|
import org.springframework.security.config.annotation.web.invoke
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class SecurityConfig {
|
class SecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
http {
|
http {
|
||||||
authorizeHttpRequests {
|
authorizeHttpRequests {
|
||||||
|
authorize("/login", permitAll)
|
||||||
authorize(anyRequest, authenticated)
|
authorize(anyRequest, authenticated)
|
||||||
}
|
}
|
||||||
formLogin { }
|
formLogin { }
|
||||||
|
@ -483,22 +489,22 @@ Java::
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class SecurityConfig {
|
public class SecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
// ...
|
// ...
|
||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public UserDetailsService userDetailsService() {
|
public UserDetailsService userDetailsService() {
|
||||||
// Return a UserDetailsService that caches users
|
// Return a UserDetailsService that caches users
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void configure(AuthenticationManagerBuilder builder) {
|
public void configure(AuthenticationManagerBuilder builder) {
|
||||||
builder.eraseCredentials(false);
|
builder.eraseCredentials(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
@ -521,8 +527,8 @@ class SecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
fun userDetailsService(): UserDetailsService {
|
fun userDetailsService(): UserDetailsService {
|
||||||
// Return a UserDetailsService that caches users
|
// Return a UserDetailsService that caches users
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
Loading…
Reference in New Issue