JAVA-29333 Upgrade spring-security-web-thymeleaf (#15699)
* JAVA-29333 Upgrade spring-security-web-thymeleaf * JAVA-29333 Fix formatting --------- Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
parent
aefb1e6cbc
commit
c499aacc87
|
@ -11,7 +11,8 @@
|
|||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>spring-security-modules</artifactId>
|
||||
<artifactId>parent-boot-3</artifactId>
|
||||
<relativePath>../../parent-boot-3</relativePath>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
|
@ -40,8 +41,12 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
|
||||
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<start-class>com.baeldung.springsecuritythymeleaf.SpringSecurityThymeleafApplication</start-class>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -7,7 +7,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -21,19 +21,14 @@ public class SecurityConfiguration {
|
|||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http.userDetailsService(userDetailsService)
|
||||
.authorizeRequests()
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
.and()
|
||||
.formLogin()
|
||||
.loginPage("/login")
|
||||
.permitAll()
|
||||
.defaultSuccessUrl("/index")
|
||||
.and()
|
||||
.logout()
|
||||
.permitAll()
|
||||
.authorizeHttpRequests(authorizationManagerRequestMatcherRegistry -> authorizationManagerRequestMatcherRegistry
|
||||
.anyRequest().authenticated())
|
||||
.formLogin(httpSecurityFormLoginConfigurer -> httpSecurityFormLoginConfigurer
|
||||
.loginPage("/login").permitAll()
|
||||
.defaultSuccessUrl("/index"))
|
||||
.logout(httpSecurityLogoutConfigurer -> httpSecurityLogoutConfigurer.permitAll()
|
||||
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
|
||||
.logoutSuccessUrl("/login");
|
||||
.logoutSuccessUrl("/login"));
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,19 +16,13 @@ public class SecurityConfiguration {
|
|||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
.and()
|
||||
.formLogin()
|
||||
.loginPage("/login")
|
||||
.permitAll()
|
||||
.successForwardUrl("/index")
|
||||
.and()
|
||||
.logout()
|
||||
.permitAll()
|
||||
http.authorizeHttpRequests(authorizationManagerRequestMatcherRegistry ->
|
||||
authorizationManagerRequestMatcherRegistry.anyRequest().authenticated())
|
||||
.formLogin(httpSecurityFormLoginConfigurer ->
|
||||
httpSecurityFormLoginConfigurer.loginPage("/login").permitAll().successForwardUrl("/index"))
|
||||
.logout(httpSecurityLogoutConfigurer -> httpSecurityLogoutConfigurer.permitAll()
|
||||
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
|
||||
.logoutSuccessUrl("/login");
|
||||
.logoutSuccessUrl("/login"));
|
||||
return http.build();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue