Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ protected void populateAuthenticationAttributes(UaaAuthentication authentication
authentication.setUserAttributes(userAttributes);

authentication.setExternalGroups(
Optional.ofNullable(authenticationData.getExternalAuthorities())
Optional.ofNullable(authenticationData.getAuthorities())
.orElse(emptyList())
.stream()
.map(GrantedAuthority::getAuthority)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ void getUser_doesThrowWhenIdTokenMappingIsWrongType() {
}

@Test
void populateAuthenticationAttributes_setsIdpIdTokenAndExternalGroups() {
void populateAuthenticationAttributes_setsIdpIdTokenAndExternalGroupsFromMappedAuthorities() {
UaaAuthentication authentication = new UaaAuthentication(new UaaPrincipal("user-guid", "marissa", "marissa@test.org", "uaa", "", ""), Collections.emptyList(), null);
Map<String, Object> header = map(
entry(HeaderParameterNames.ALGORITHM, JWSAlgorithm.RS256.getName()),
Expand All @@ -627,10 +627,11 @@ void populateAuthenticationAttributes_setsIdpIdTokenAndExternalGroups() {
String idTokenJwt = UaaTokenUtils.constructToken(header, claims, signer);
ExternalOAuthCodeToken oidcAuthentication = new ExternalOAuthCodeToken(null, ORIGIN, "http://google.com", idTokenJwt, "accesstoken", "signedrequest");
ExternalOAuthAuthenticationManager.AuthenticationData authenticationData = authManager.getExternalAuthenticationDetails(oidcAuthentication);
authenticationData.setExternalAuthorities(List.of(new SimpleGrantedAuthority("uaa-authorities")));
authenticationData.setAuthorities(List.of(new SimpleGrantedAuthority("uaa-authorities")));
authenticationData.setExternalAuthorities(List.of(new SimpleGrantedAuthority("raw_external_group")));
authManager.populateAuthenticationAttributes(authentication, oidcAuthentication, authenticationData);
assertThat(authentication.getIdpIdToken()).isEqualTo(idTokenJwt);
assertThat(authentication.getExternalGroups()).containsAll(List.of("uaa-authorities"));
assertThat(authentication.getExternalGroups()).containsExactlyInAnyOrder("uaa-authorities");
}

@Test
Expand Down
Loading