Skip to content

Commit

Permalink
Merge pull request #29 from pavelfomin/feature/web-security-deprecate…
Browse files Browse the repository at this point in the history
…d-api

Remove deprecated spring security api usage
  • Loading branch information
pavelfomin committed Oct 27, 2023
2 parents 3a6e76c + baf61d7 commit 2fb7013
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
Expand All @@ -15,7 +15,7 @@

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableMethodSecurity
public class WebSecurityConfig {

@Value("${app.security.ignore:/swagger/**, /swagger-resources/**, /swagger-ui/**, /swagger-ui.html, /webjars/**, /v3/api-docs/**, /actuator/info}")
Expand All @@ -25,16 +25,16 @@ public class WebSecurityConfig {
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

http
.csrf(AbstractHttpConfigurer::disable)
.authorizeRequests()
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(customizer -> customizer
//make sure principal is created for the health endpoint to verify the role
.requestMatchers(new AntPathRequestMatcher("/actuator/health"))
.permitAll()
.anyRequest()
.authenticated()
.and()
.oauth2ResourceServer((configurer) -> configurer.jwt(Customizer.withDefaults()))
.sessionManagement((s) -> s.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
)
.oauth2ResourceServer((configurer) -> configurer.jwt(Customizer.withDefaults()))
.sessionManagement((s) -> s.sessionCreationPolicy(SessionCreationPolicy.STATELESS));

return http.build();
}
Expand Down

0 comments on commit 2fb7013

Please sign in to comment.