Skip to content

Commit

Permalink
Merge branch 'main' into bug/fix-configs
Browse files Browse the repository at this point in the history
  • Loading branch information
masonwoodford authored May 25, 2024
2 parents 28a34ad + 0f2ca72 commit 9782a6f
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 72 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ To run Kafbat UI, you can use either a pre-built Docker image or build it (or a
## Quick start (Demo run)

```
docker run -it -p 8080:8080 -e DYNAMIC_CONFIG_ENABLED=true image: ghcr.io/kafbat/kafka-ui
docker run -it -p 8080:8080 -e DYNAMIC_CONFIG_ENABLED=true ghcr.io/kafbat/kafka-ui
```

Then access the web UI at [http://localhost:8080](http://localhost:8080)
Expand Down
3 changes: 1 addition & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#FROM azul/zulu-openjdk-alpine:17-jre-headless
FROM azul/zulu-openjdk-alpine@sha256:d59f1266db40341318e563fd76c21b2880ffa5d371f0c097c29d33f89c3a0010
FROM azul/zulu-openjdk-alpine:17.0.11-jre-headless

RUN apk add --no-cache \
# snappy codec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import io.kafbat.ui.serdes.BuiltInSerde;
import io.kafbat.ui.util.jsonschema.ProtobufSchemaConverter;
import java.io.ByteArrayInputStream;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
Expand Down Expand Up @@ -404,7 +405,7 @@ private Loader createFilesLoader(Map<String, ProtoFile> files) {
@SneakyThrows
private Map<String, ProtoFile> loadFilesWithLocations() {
Map<String, ProtoFile> filesByLocations = new HashMap<>();
try (var files = Files.walk(baseLocation)) {
try (var files = Files.walk(baseLocation, FileVisitOption.FOLLOW_LINKS)) {
files.filter(p -> !Files.isDirectory(p) && p.toString().endsWith(".proto"))
.forEach(path -> {
// relative path will be used as "import" statement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package io.kafbat.ui.service.rbac.extractor;

import io.kafbat.ui.config.auth.LdapProperties;
import io.kafbat.ui.model.rbac.Role;
import io.kafbat.ui.model.rbac.provider.Provider;
import io.kafbat.ui.service.rbac.AccessControlService;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -14,25 +11,26 @@
import org.springframework.ldap.core.support.BaseLdapPathContextSource;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator;
import org.springframework.util.Assert;
import org.springframework.security.ldap.userdetails.NestedLdapAuthoritiesPopulator;

@Slf4j
public class RbacLdapAuthoritiesExtractor extends DefaultLdapAuthoritiesPopulator {
public class RbacLdapAuthoritiesExtractor extends NestedLdapAuthoritiesPopulator {

private final AccessControlService acs;
private final LdapProperties props;

public RbacLdapAuthoritiesExtractor(ApplicationContext context,
BaseLdapPathContextSource contextSource, String groupFilterSearchBase) {
super(contextSource, groupFilterSearchBase);
this.acs = context.getBean(AccessControlService.class);
this.props = context.getBean(LdapProperties.class);
}

@Override
protected Set<GrantedAuthority> getAdditionalRoles(DirContextOperations user, String username) {
var ldapGroups = getRoles(user.getNameInNamespace(), username);
var ldapGroups = super.getGroupMembershipRoles(user.getNameInNamespace(), username)
.stream()
.map(GrantedAuthority::getAuthority)
.peek(group -> log.trace("Found LDAP group [{}] for user [{}]", group, username))
.collect(Collectors.toSet());

return acs.getRoles()
.stream()
Expand All @@ -47,32 +45,4 @@ protected Set<GrantedAuthority> getAdditionalRoles(DirContextOperations user, St
.map(SimpleGrantedAuthority::new)
.collect(Collectors.toSet());
}

private Set<String> getRoles(String userDn, String username) {
var groupSearchBase = props.getGroupFilterSearchBase();
Assert.notNull(groupSearchBase, "groupSearchBase is empty");

var groupRoleAttribute = props.getGroupRoleAttribute();
if (groupRoleAttribute == null) {

groupRoleAttribute = "cn";
}

log.trace(
"Searching for roles for user [{}] with DN [{}], groupRoleAttribute [{}] and filter [{}] in search base [{}]",
username, userDn, groupRoleAttribute, getGroupSearchFilter(), groupSearchBase);

var ldapTemplate = getLdapTemplate();
ldapTemplate.setIgnoreNameNotFoundException(true);

Set<Map<String, List<String>>> userRoles = ldapTemplate.searchForMultipleAttributeValues(
groupSearchBase, getGroupSearchFilter(), new String[] {userDn, username},
new String[] {groupRoleAttribute});

return userRoles.stream()
.map(record -> record.get(getGroupRoleAttribute()).get(0))
.peek(group -> log.trace("Found LDAP group [{}] for user [{}]", group, username))
.collect(Collectors.toSet());
}

}
2 changes: 1 addition & 1 deletion api/src/main/java/io/kafbat/ui/util/GithubReleaseInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class GithubReleaseInfo {
private static final String GITHUB_LATEST_RELEASE_RETRIEVAL_URL =
"https://api.github.com/repos/kafbat/kafka-ui/releases/latest";

private static final Duration GITHUB_API_MAX_WAIT_TIME = Duration.ofSeconds(2);
private static final Duration GITHUB_API_MAX_WAIT_TIME = Duration.ofSeconds(10);

public record GithubReleaseDto(String html_url, String tag_name, String published_at) {

Expand Down
1 change: 1 addition & 0 deletions contract/src/main/resources/swagger/kafbat-ui-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3471,6 +3471,7 @@ components:
- PAUSED
- UNASSIGNED
- TASK_FAILED
- RESTARTING

ConnectorAction:
type: string
Expand Down
1 change: 1 addition & 0 deletions contract/src/main/resources/swagger/kafka-connect-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ components:
- FAILED
- PAUSED
- UNASSIGNED
- RESTARTING
worker_id:
type: string
trace:
Expand Down
8 changes: 4 additions & 4 deletions documentation/compose/kafbat-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ services:
- "9093:9092"
- "9998:9998"
environment:
KAFKA_BROKER_ID: 1
KAFKA_BROKER_ID: 2
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT'
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://kafka1:29092,PLAINTEXT_HOST://localhost:9092'
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_JMX_PORT: 9998
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka0 -Dcom.sun.management.jmxremote.rmi.port=9998
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka1 -Dcom.sun.management.jmxremote.rmi.port=9998
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_NODE_ID: 1
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka1:29093'
KAFKA_NODE_ID: 2
KAFKA_CONTROLLER_QUORUM_VOTERS: '2@kafka1:29093'
KAFKA_LISTENERS: 'PLAINTEXT://kafka1:29092,CONTROLLER://kafka1:29093,PLAINTEXT_HOST://0.0.0.0:9092'
KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT'
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"react-hot-toast": "2.4.1",
"react-is": "18.2.0",
"react-multi-select-component": "4.3.4",
"react-router-dom": "6.4.3",
"react-router-dom": "6.23.0",
"sass": "1.66.1",
"styled-components": "6.1.8",
"use-debounce": "10.0.0",
Expand Down
28 changes: 14 additions & 14 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/components/Topics/shared/Form/TopicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const TopicForm: React.FC<Props> = ({
id="topicFormRetentionBytesLabel"
htmlFor="topicFormRetentionBytes"
>
Max size on disk in GB
Max partition size in GB
</InputLabel>
<Controller
control={control}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('TopicForm', () => {
expectByRoleAndNameToBeInDocument('button', '7 days');
expectByRoleAndNameToBeInDocument('button', '4 weeks');

expectByRoleAndNameToBeInDocument('listbox', 'Max size on disk in GB');
expectByRoleAndNameToBeInDocument('listbox', 'Max partition size in GB');
expectByRoleAndNameToBeInDocument(
'spinbutton',
'Maximum message size in bytes'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/common/Select/Select.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const OptionList = styled.ul`
line-height: 18px;
color: ${({ theme }) => theme.select.color.normal};
overflow-y: auto;
z-index: 10;
z-index: 12;
max-width: 300px;
min-width: 100%;
align-items: center;
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/lib/hooks/api/topicMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ export const useTopicMessages = ({
default:
}

searchParams.getAll(MessagesFilterKeys.partitions).forEach((value) => {
requestParams.append(MessagesFilterKeys.partitions, value);
});

const partitions = searchParams.get(MessagesFilterKeys.partitions);
if (partitions !== null) {
requestParams.append(MessagesFilterKeys.partitions, partitions);
}
const { nextCursor, setNextCursor } = useMessageFiltersStore.getState();

const tempCompareUrl = new URLSearchParams(requestParams);
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/lib/hooks/useMessagesFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export function useMessagesFilters() {

const search = searchParams.get(MessagesFilterKeys.stringFilter) || '';

const partitions = searchParams.getAll(MessagesFilterKeys.partitions);
const partitions = (searchParams.get(MessagesFilterKeys.partitions) || '')
.split(',')
.filter((v) => v);

const smartFilterId =
searchParams.get(MessagesFilterKeys.activeFilterId) ||
Expand Down Expand Up @@ -166,9 +168,12 @@ export function useMessagesFilters() {
setSearchParams((params) => {
params.delete(MessagesFilterKeys.partitions);

values.forEach((option) => {
params.append(MessagesFilterKeys.partitions, option.value);
});
if (values.length) {
params.append(
MessagesFilterKeys.partitions,
values.map((v) => v.value).join(',')
);
}

return params;
});
Expand Down

0 comments on commit 9782a6f

Please sign in to comment.