I'm building an app using Spring security and deploying it on Cloud Run behind IAP, and I want to retrieve the GCP groups of the user to give him permission or not to access APIs.
I've tried to use Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
, and succeeded in retrieving email from jwt token using authentication.getPrincipal().getClaimAsString("email")
.
However, I thought I may find the groups in authentication.getAuthorities()
but it returns an empty list.
Is there a way, with a library or something, to retrieve those groups ?