Skip to content
Snippets Groups Projects
Verified Commit a4656c67 authored by Dominik Frantisek Bucik's avatar Dominik Frantisek Bucik
Browse files

fix: :bug: Losing AUD in GA4GH AT modifier

Audiences previously set in the token were lost as the current
implementation just placed ClientID over it. The fix maintains set
audiences
parent 948b33a3
Branches
Tags
1 merge request!399fix: 🐛 Losing AUD in GA4GH AT modifier
Pipeline #452960 passed
This commit is part of merge request !399. Comments created here will be created in the context of that merge request.
......@@ -8,7 +8,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import static cz.muni.ics.oidc.server.ga4gh.Ga4ghApiClaimSource.GA4GH_SCOPE;
......@@ -33,8 +36,15 @@ public class Ga4ghAccessTokenModifier implements PerunAccessTokenEnhancer.Access
Set<String> scopes = accessToken.getScope();
//GA4GH
if (scopes.contains(GA4GH_SCOPE)) {
Object originalAud = builder.getClaims().get("aud");
Set<String> newAud = new HashSet<>();
if (originalAud instanceof String) {
newAud.add((String) originalAud);
} else if (originalAud instanceof Collection) {
newAud.addAll((Collection<String>) originalAud);
}
log.debug("Adding claims required by GA4GH to access token");
builder.audience(Collections.singletonList(authentication.getOAuth2Request().getClientId()));
builder.audience(new ArrayList<>(newAud));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment