Skip to content

Commit

Permalink
Return groups in indentity response
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-walkiewicz authored and kokosing committed Jan 24, 2022
1 parent f186a03 commit 00ce676
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.collect.Iterables.getOnlyElement;
Expand Down Expand Up @@ -820,8 +822,14 @@ public javax.ws.rs.core.Response echoToken(@Context HttpServletRequest servletRe
return javax.ws.rs.core.Response.ok()
.header("user", identity.getUser())
.header("principal", identity.getPrincipal().map(Principal::getName).orElse(null))
.header("groups", toHeader(identity.getGroups()))
.build();
}

public static String toHeader(Set<String> groups)
{
return groups.stream().sorted().collect(Collectors.joining(","));
}
}

private void assertInsecureAuthentication(URI baseUri)
Expand Down

0 comments on commit 00ce676

Please sign in to comment.