Skip to content

Commit

Permalink
fix(auth): get all values from auth header in header auth (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasK33 authored and tchiotludo committed Apr 4, 2023
1 parent cc20b74 commit 2372776
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/org/akhq/modules/HeaderAuthenticationFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -86,17 +87,19 @@ public Publisher<Authentication> fetchAuthentication(HttpRequest<?> request) {
log.debug("One or more of the IP patterns matched the host address [{}]. Continuing request processing.", hostAddress);
}

Optional<String> groupHeaders = headerAuth.getGroupsHeader() != null ?
request.getHeaders().get(headerAuth.getGroupsHeader(), String.class) :
Optional.empty();
List<String> groupsHeader = headerAuth.getGroupsHeader() != null ?
request.getHeaders().getAll(headerAuth.getGroupsHeader()) :
Collections.emptyList();

return Flowable
.fromCallable(() -> {
List<String> groups = groupHeaders
List<String> groups = groupsHeader
.stream()
.flatMap(s -> Arrays.stream(s.split(headerAuth.getGroupsHeaderSeparator())))
.collect(Collectors.toList());

log.debug("Got groups [{}] from groupsHeader [{}] and separator [{}]", groups, groupsHeader, headerAuth.getGroupsHeaderSeparator());

ClaimRequest claim =
ClaimRequest.builder()
.providerType(ClaimProviderType.HEADER)
Expand Down

0 comments on commit 2372776

Please sign in to comment.