29 lines
1.1 KiB
Java
29 lines
1.1 KiB
Java
|
|
package com.gcsc.guide.config;
|
||
|
|
|
||
|
|
import org.springframework.context.annotation.Bean;
|
||
|
|
import org.springframework.context.annotation.Configuration;
|
||
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||
|
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||
|
|
import org.springframework.security.web.SecurityFilterChain;
|
||
|
|
|
||
|
|
@Configuration
|
||
|
|
@EnableWebSecurity
|
||
|
|
public class SecurityConfig {
|
||
|
|
|
||
|
|
@Bean
|
||
|
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||
|
|
http
|
||
|
|
.csrf(csrf -> csrf.disable())
|
||
|
|
.sessionManagement(session ->
|
||
|
|
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||
|
|
.authorizeHttpRequests(auth -> auth
|
||
|
|
.requestMatchers("/api/auth/**", "/actuator/health", "/h2-console/**").permitAll()
|
||
|
|
.anyRequest().authenticated()
|
||
|
|
)
|
||
|
|
.headers(headers -> headers.frameOptions(frame -> frame.sameOrigin()));
|
||
|
|
|
||
|
|
return http.build();
|
||
|
|
}
|
||
|
|
}
|