mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-22 08:08:01 +00:00
feat(oidc): Adding support for extracting single string groups claim (#4419)
This commit is contained in:
parent
86f240769f
commit
11f809abd2
@ -245,8 +245,22 @@ public class OidcCallbackLogic extends DefaultCallbackLogic<Result, PlayWebConte
|
||||
if (profile.containsAttribute(groupsClaimName)) {
|
||||
try {
|
||||
final List<CorpGroupSnapshot> groupSnapshots = new ArrayList<>();
|
||||
// We found some groups. Note that we assume it is an array of strings!
|
||||
final Collection<String> groupNames = (Collection<String>) profile.getAttribute(groupsClaimName, Collection.class);
|
||||
final Collection<String> groupNames;
|
||||
final Object groupAttribute = profile.getAttribute(groupsClaimName);
|
||||
if (groupAttribute instanceof Collection) {
|
||||
// List of group names
|
||||
groupNames = (Collection<String>) profile.getAttribute(groupsClaimName, Collection.class);
|
||||
} else if (groupAttribute instanceof String) {
|
||||
// Single group name
|
||||
groupNames = Collections.singleton(profile.getAttribute(groupsClaimName, String.class));
|
||||
} else {
|
||||
log.error(String.format("Failed to parse OIDC group claim with name %s. Unknown type %s provided.",
|
||||
groupsClaimName,
|
||||
groupAttribute.getClass()));
|
||||
// Return empty list. Do not throw.
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
for (String groupName : groupNames) {
|
||||
// Create a basic CorpGroupSnapshot from the information.
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user