Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-cartwright committed Dec 21, 2023
1 parent 78c7d36 commit 749a3a1
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions datahub-frontend/app/auth/sso/oidc/OidcCallbackLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import auth.sso.SsoManager;
import client.AuthServiceClient;
import com.datahub.authentication.Authentication;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.linkedin.common.AuditStamp;
import com.linkedin.common.CorpGroupUrnArray;
import com.linkedin.common.CorpuserUrnArray;
Expand Down Expand Up @@ -66,9 +69,6 @@
import org.pac4j.core.util.Pac4jConstants;
import org.pac4j.play.PlayWebContext;
import play.mvc.Result;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;


/**
Expand Down Expand Up @@ -304,16 +304,19 @@ private CorpUserSnapshot extractUser(CorpuserUrn urn, CommonProfile profile) {
return corpUserSnapshot;
}

public static List<String> getGroupsClaimNames (OidcConfigs configs) {
List<String> groupsClaimNames = new ArrayList<>();
public static List<String> getGroupsClaimNames(OidcConfigs configs) {
List<String> groupsClaimNames;
String rawGroupClaimsNames = configs.getGroupsClaimName();
if (rawGroupClaimsNames.startsWith("[") && rawGroupClaimsNames.endsWith("]")){
Type listType = new TypeToken<Collection<String>>(){}.getType();
groupsClaimNames = new Gson().fromJson(rawGroupClaimsNames, listType);
} else {
groupsClaimNames = new ArrayList<String>(Arrays.asList(rawGroupClaimsNames.split(",")))
.stream().map(String::trim).collect(Collectors.toList());
ObjectMapper objectMapper = new ObjectMapper();

try {
groupsClaimNames = objectMapper.readValue(rawGroupClaimsNames, new TypeReference<List<String>>(){});
} catch (JsonProcessingException e) {
groupsClaimNames = Arrays.stream(rawGroupClaimsNames.split(","))
.map(String::trim)
.collect(Collectors.toList());
}

return groupsClaimNames;
}

Expand Down

0 comments on commit 749a3a1

Please sign in to comment.