Introduce support for multi-valued role mapping for oauth#9872
Introduce support for multi-valued role mapping for oauth#9872evandongen merged 6 commits intomasterfrom
Conversation
| public static List<Arguments> data() { | ||
| return Arrays.asList(new Arguments[]{ | ||
| Arguments.of("roles", Map.of("roles", List.of("IbisAdmin"))), | ||
| Arguments.of("realm_access.roles", Map.of("realm_access", Map.of("roles", List.of("IbisAdmin")))) |
There was a problem hiding this comment.
Ik bedenk me net dat hier eigenlijk nog een List.of meerdere rollen in moet ipv alleen een single valued list.
| return getRolesFromUserInfo(oidcUserAuthority.getUserInfo()).stream().toList(); | ||
| } else if (authority instanceof OAuth2UserAuthority oAuth2UserAuthority) { | ||
| return getKeyValues(oAuth2UserAuthority.getAttributes()); | ||
| } |
There was a problem hiding this comment.
Moet er misschien nog een else throw new IllegalArgumentException() voor wanneer de authority geen instance is van beide classes? Of is dat een geldige situatie?
There was a problem hiding this comment.
Dat is in principe hierboven al gefilterd. Als je Oauth2 gebruikt is er altijd een Oauth2UserAuthority volgens spring, al dan niet van het child-type OidcUserAuthority.
| Map<String, Collection<String>> realmAccess = (Map<String, Collection<String>>) userAttributes.get(keyParts[0]); | ||
|
|
||
| // get second part of the key | ||
| return (List<String>) realmAccess.get(keyParts[1]); |
There was a problem hiding this comment.
Is it possible for the key to contain multiple . separators?
What happens the key ends with a .?
What if the claim does not exist, or is not in form of a List<String>?
There was a problem hiding this comment.
Dit is afgedekt door de configure() methode in Oauth2Authenticator, die doet hetzelfde als de bearer only authenticator en support alleen maar 1 punt in deze string. Ik zal dat nog even toevoegen als comment, want Vivy vroeg zich dit ook al af :-)
|



Changes
Added support for a list of roles to be mapped using
oauth-role-mapping.properties.Pull Request Checklist
Title
Issues
Documentation
FF! Manual updated (if applicable)Javadoc updated/generated (developer-facing APIs)Tests
E2E/Integration tests added/updated (if applicable)