Skip to content

Commit 892fa47

Browse files
committed
Merge branch 'main' into ad_it_test
2 parents 1c358bd + 582e9a9 commit 892fa47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1435
-292
lines changed

.java-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
21

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright 2020 CloudHut
190+
Copyright 2025 Kafbat
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.
@@ -199,4 +199,4 @@
199199
distributed under the License is distributed on an "AS IS" BASIS,
200200
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201201
See the License for the specific language governing permissions and
202-
limitations under the License.
202+
limitations under the License.

api/src/main/java/io/kafbat/ui/config/ClustersProperties.java

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,31 @@ public class ClustersProperties {
3535
public static class Cluster {
3636
String name;
3737
String bootstrapServers;
38+
39+
TruststoreConfig ssl;
40+
3841
String schemaRegistry;
3942
SchemaRegistryAuth schemaRegistryAuth;
4043
KeystoreConfig schemaRegistrySsl;
44+
4145
String ksqldbServer;
4246
KsqldbServerAuth ksqldbServerAuth;
4347
KeystoreConfig ksqldbServerSsl;
48+
4449
List<ConnectCluster> kafkaConnect;
45-
MetricsConfigData metrics;
46-
Map<String, Object> properties;
47-
boolean readOnly = false;
50+
4851
List<SerdeConfig> serde;
4952
String defaultKeySerde;
5053
String defaultValueSerde;
51-
List<Masking> masking;
54+
55+
MetricsConfigData metrics;
56+
Map<String, Object> properties;
57+
boolean readOnly = false;
58+
5259
Long pollingThrottleRate;
53-
TruststoreConfig ssl;
60+
61+
List<Masking> masking;
62+
5463
AuditProperties audit;
5564
}
5665

@@ -99,6 +108,16 @@ public static class SchemaRegistryAuth {
99108
public static class TruststoreConfig {
100109
String truststoreLocation;
101110
String truststorePassword;
111+
boolean verifySsl = true;
112+
}
113+
114+
@Data
115+
@NoArgsConstructor
116+
@AllArgsConstructor
117+
@ToString(exclude = {"keystorePassword"})
118+
public static class KeystoreConfig {
119+
String keystoreLocation;
120+
String keystorePassword;
102121
}
103122

104123
@Data
@@ -118,15 +137,6 @@ public static class KsqldbServerAuth {
118137
String password;
119138
}
120139

121-
@Data
122-
@NoArgsConstructor
123-
@AllArgsConstructor
124-
@ToString(exclude = {"keystorePassword"})
125-
public static class KeystoreConfig {
126-
String keystoreLocation;
127-
String keystorePassword;
128-
}
129-
130140
@Data
131141
public static class Masking {
132142
Type type;
@@ -182,6 +192,7 @@ private void flattenClusterProperties() {
182192
}
183193
}
184194

195+
@SuppressWarnings("unchecked")
185196
private Map<String, Object> flattenClusterProperties(@Nullable String prefix,
186197
@Nullable Map<String, Object> propertiesMap) {
187198
Map<String, Object> flattened = new HashMap<>();
Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,53 @@
11
package io.kafbat.ui.config.auth;
22

3+
import io.kafbat.ui.util.EmptyRedirectStrategy;
4+
import java.net.URI;
5+
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler;
6+
import org.springframework.security.web.server.authentication.logout.RedirectServerLogoutSuccessHandler;
7+
38
abstract class AbstractAuthSecurityConfig {
49

510
protected AbstractAuthSecurityConfig() {
611

712
}
813

14+
protected static final String LOGIN_URL = "/login";
15+
protected static final String LOGOUT_URL = "/auth?logout";
16+
917
protected static final String[] AUTH_WHITELIST = {
10-
"/css/**",
11-
"/js/**",
12-
"/media/**",
18+
/* STATIC */
19+
"/index.html",
20+
"/assets/**",
21+
"/manifest.json",
22+
"/favicon.svg",
23+
"/favicon/**",
24+
25+
"/static/**",
1326
"/resources/**",
27+
28+
/* ACTUATOR */
1429
"/actuator/health/**",
1530
"/actuator/info",
1631
"/actuator/prometheus",
17-
"/auth",
32+
33+
/* AUTH */
1834
"/login",
1935
"/logout",
2036
"/oauth2/**",
21-
"/static/**"
37+
"/api/config/authentication",
38+
"/api/authorization"
2239
};
2340

41+
protected RedirectServerAuthenticationSuccessHandler emptyRedirectSuccessHandler() {
42+
final var authHandler = new RedirectServerAuthenticationSuccessHandler();
43+
authHandler.setRedirectStrategy(new EmptyRedirectStrategy());
44+
return authHandler;
45+
}
46+
47+
protected RedirectServerLogoutSuccessHandler redirectLogoutSuccessHandler() {
48+
final var logoutSuccessHandler = new RedirectServerLogoutSuccessHandler();
49+
logoutSuccessHandler.setLogoutSuccessUrl(URI.create(LOGOUT_URL));
50+
return logoutSuccessHandler;
51+
}
52+
2453
}
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package io.kafbat.ui.config.auth;
22

33
import io.kafbat.ui.util.EmptyRedirectStrategy;
4+
import io.kafbat.ui.util.StaticFileWebFilter;
45
import java.net.URI;
56
import lombok.extern.slf4j.Slf4j;
67
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
78
import org.springframework.context.annotation.Bean;
89
import org.springframework.context.annotation.Configuration;
910
import org.springframework.http.HttpMethod;
1011
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
12+
import org.springframework.security.config.web.server.SecurityWebFiltersOrder;
1113
import org.springframework.security.config.web.server.ServerHttpSecurity;
1214
import org.springframework.security.web.server.SecurityWebFilterChain;
1315
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler;
@@ -20,32 +22,28 @@
2022
@Slf4j
2123
public class BasicAuthSecurityConfig extends AbstractAuthSecurityConfig {
2224

23-
public static final String LOGIN_URL = "/auth";
24-
public static final String LOGOUT_URL = "/auth?logout";
25-
2625
@Bean
2726
public SecurityWebFilterChain configure(ServerHttpSecurity http) {
2827
log.info("Configuring LOGIN_FORM authentication.");
2928

30-
final var authHandler = new RedirectServerAuthenticationSuccessHandler();
31-
authHandler.setRedirectStrategy(new EmptyRedirectStrategy());
32-
33-
final var logoutSuccessHandler = new RedirectServerLogoutSuccessHandler();
34-
logoutSuccessHandler.setLogoutSuccessUrl(URI.create(LOGOUT_URL));
35-
36-
37-
return http.authorizeExchange(spec -> spec
29+
var builder = http.authorizeExchange(spec -> spec
3830
.pathMatchers(AUTH_WHITELIST)
3931
.permitAll()
4032
.anyExchange()
4133
.authenticated()
4234
)
43-
.formLogin(spec -> spec.loginPage(LOGIN_URL).authenticationSuccessHandler(authHandler))
35+
.formLogin(form -> form
36+
.loginPage(LOGIN_URL)
37+
.authenticationSuccessHandler(emptyRedirectSuccessHandler())
38+
)
4439
.logout(spec -> spec
45-
.logoutSuccessHandler(logoutSuccessHandler)
40+
.logoutSuccessHandler(redirectLogoutSuccessHandler())
4641
.requiresLogout(ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, "/logout")))
47-
.csrf(ServerHttpSecurity.CsrfSpec::disable)
48-
.build();
42+
.csrf(ServerHttpSecurity.CsrfSpec::disable);
43+
44+
builder.addFilterAt(new StaticFileWebFilter(), SecurityWebFiltersOrder.LOGIN_PAGE_GENERATING);
45+
46+
return builder.build();
4947
}
5048

5149
}

0 commit comments

Comments
 (0)