Skip to content

Commit 4ed5f2d

Browse files
authored
Add optional authentication (#67)
* Add optional authentication * Add example config for Google OAuth
1 parent 7b61a9b commit 4ed5f2d

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

kafka-ui-api/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
</exclusion>
3535
</exclusions>
3636
</dependency>
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-security</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.springframework.security</groupId>
43+
<artifactId>spring-security-oauth2-client</artifactId>
44+
</dependency>
3745
<dependency>
3846
<groupId>com.provectus</groupId>
3947
<artifactId>kafka-ui-contract</artifactId>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.provectus.kafka.ui.cluster.config;
2+
3+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
7+
import org.springframework.security.config.web.server.ServerHttpSecurity;
8+
import org.springframework.security.web.server.SecurityWebFilterChain;
9+
10+
@Configuration
11+
@EnableWebFluxSecurity
12+
@ConditionalOnProperty(value = "auth.enabled", havingValue = "false")
13+
public class SecurityConfig {
14+
15+
@Bean
16+
public SecurityWebFilterChain configure(ServerHttpSecurity http) {
17+
return http.authorizeExchange()
18+
.anyExchange().permitAll()
19+
.and()
20+
.csrf().disable()
21+
.build();
22+
}
23+
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
auth:
2+
enabled: true
3+
spring:
4+
security:
5+
oauth2:
6+
client:
7+
registration:
8+
google:
9+
client-id: [put your client id here]
10+
client-secret: [put your client secret here]

kafka-ui-api/src/main/resources/application-local.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ zookeeper:
2222
connection-timeout: 1000
2323
spring:
2424
jmx:
25-
enabled: true
25+
enabled: true
26+
auth:
27+
enabled: false

0 commit comments

Comments
 (0)