Add optional authentication (#67)
* Add optional authentication * Add example config for Google OAuth
This commit is contained in:
parent
7b61a9b51d
commit
4ed5f2dd10
4 changed files with 45 additions and 1 deletions
|
@ -34,6 +34,14 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-oauth2-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.provectus</groupId>
|
||||
<artifactId>kafka-ui-contract</artifactId>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.provectus.kafka.ui.cluster.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 = "false")
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain configure(ServerHttpSecurity http) {
|
||||
return http.authorizeExchange()
|
||||
.anyExchange().permitAll()
|
||||
.and()
|
||||
.csrf().disable()
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
10
kafka-ui-api/src/main/resources/application-gauth.yml
Normal file
10
kafka-ui-api/src/main/resources/application-gauth.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
auth:
|
||||
enabled: true
|
||||
spring:
|
||||
security:
|
||||
oauth2:
|
||||
client:
|
||||
registration:
|
||||
google:
|
||||
client-id: [put your client id here]
|
||||
client-secret: [put your client secret here]
|
|
@ -22,4 +22,6 @@ zookeeper:
|
|||
connection-timeout: 1000
|
||||
spring:
|
||||
jmx:
|
||||
enabled: true
|
||||
enabled: true
|
||||
auth:
|
||||
enabled: false
|
Loading…
Add table
Reference in a new issue