Skip to content
Snippets Groups Projects
Commit 8cfd0050 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

fixed deprecated spring security config

parent 6c34e223
Branches
Tags
No related merge requests found
...@@ -3,6 +3,7 @@ package de.deadlocker8.budgetmaster.authentication; ...@@ -3,6 +3,7 @@ package de.deadlocker8.budgetmaster.authentication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.LogoutConfigurer;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.DefaultRedirectStrategy; import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy; import org.springframework.security.web.RedirectStrategy;
...@@ -20,21 +21,18 @@ public class WebSecurityConfig ...@@ -20,21 +21,18 @@ public class WebSecurityConfig
return new BCryptPasswordEncoder(); return new BCryptPasswordEncoder();
} }
@Bean @Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception public SecurityFilterChain filterChain(HttpSecurity http) throws Exception
{ {
http http
.csrf() .csrf(csrf -> csrf.configure(http))
.and() .authorizeHttpRequests(authorization -> authorization
.authorizeHttpRequests()
.requestMatchers("/css/**", "/js/**", "/images/**", "/webjars/**", "/favicon.ico", "/touch_icon.png").permitAll() .requestMatchers("/css/**", "/js/**", "/images/**", "/webjars/**", "/favicon.ico", "/touch_icon.png").permitAll()
.requestMatchers("/login").permitAll() .requestMatchers("/login").permitAll()
.requestMatchers("/**").authenticated() .requestMatchers("/**").authenticated())
.and() .formLogin(formLogin -> formLogin
.formLogin()
.loginPage("/login") .loginPage("/login")
.permitAll()
.successHandler((req, res, auth) -> { .successHandler((req, res, auth) -> {
Object preLoginURL = req.getSession().getAttribute("preLoginURL"); Object preLoginURL = req.getSession().getAttribute("preLoginURL");
if(preLoginURL == null || preLoginUrlBlacklist.isBlacklisted(preLoginURL.toString())) if(preLoginURL == null || preLoginUrlBlacklist.isBlacklisted(preLoginURL.toString()))
...@@ -44,10 +42,9 @@ public class WebSecurityConfig ...@@ -44,10 +42,9 @@ public class WebSecurityConfig
redirectStrategy.sendRedirect(req, res, preLoginURL.toString()); redirectStrategy.sendRedirect(req, res, preLoginURL.toString());
}) })
.permitAll() .permitAll()
.and() )
.logout(LogoutConfigurer::permitAll
.logout() );
.permitAll();
return http.build(); return http.build();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment