ISSUE-788 Added oauth2 security config (#822)

This commit is contained in:
German Osin 2021-08-25 20:27:17 +03:00 committed by GitHub
parent d737953a8e
commit 63059ffa28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,40 @@
package com.provectus.kafka.ui.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
@Configuration
@EnableWebFluxSecurity
@ConditionalOnProperty(value = "auth.enabled", havingValue = "true")
public class OAuthSecurityConfig {
private static final String[] AUTH_WHITELIST = {
"/css/**",
"/js/**",
"/media/**",
"/resources/**",
"/actuator/health",
"/actuator/info",
"/login",
"/logout",
"/oauth2/**"
};
@Bean
public SecurityWebFilterChain configure(ServerHttpSecurity http) {
return http.authorizeExchange()
.pathMatchers(AUTH_WHITELIST).permitAll()
.anyExchange().authenticated()
.and()
.oauth2Login()
.and()
.csrf().disable()
.build();
}
}