Skip to content
Snippets Groups Projects
Commit 0c7ce7f9 authored by Dominik František Bučík's avatar Dominik František Bučík
Browse files

chore: merge branch 'dBucik/fix_ga4gh_at_modifier' into 'main'

fix: :bug: Losing AUD in GA4GH AT modifier

See merge request !399
parents 063b15f9 a4656c67
No related branches found
No related tags found
1 merge request!399fix: 🐛 Losing AUD in GA4GH AT modifier
Pipeline #452967 passed
......@@ -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