mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-22 16:18:10 +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)) {
|
if (profile.containsAttribute(groupsClaimName)) {
|
||||||
try {
|
try {
|
||||||
final List<CorpGroupSnapshot> groupSnapshots = new ArrayList<>();
|
final List<CorpGroupSnapshot> groupSnapshots = new ArrayList<>();
|
||||||
// We found some groups. Note that we assume it is an array of strings!
|
final Collection<String> groupNames;
|
||||||
final Collection<String> groupNames = (Collection<String>) profile.getAttribute(groupsClaimName, Collection.class);
|
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) {
|
for (String groupName : groupNames) {
|
||||||
// Create a basic CorpGroupSnapshot from the information.
|
// Create a basic CorpGroupSnapshot from the information.
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user