feat(java-cache): add SecurityConfig.java (2/6)

This commit is contained in:
hoelee committed 2020-11-03 11:29:00 +08:00
1 parent cfaea7cc3c
commit e4e719e977
1 file changed
+13
@@ -23,5 +23,18 @@ import org.springframework.security.web.SecurityFilterChain;
public class SecurityConfig {
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.csrf(AbstractHttpConfigurer::disable)
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/", "/index.html", "/css/**", "/js/**", "/actuator/health").permitAll()
.requestMatchers(HttpMethod.GET, "/api/**").permitAll()
.requestMatchers("/api/**").hasRole("EDITOR")
.anyRequest().denyAll())
.httpBasic(Customizer.withDefaults())
.build();
}
}