Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DCR PUT request not updating application role audience #2669

Merged
merged 1 commit into from
Jan 9, 2025
Merged
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 @@ -310,13 +310,24 @@ public Application updateApplication(ApplicationUpdateRequest updateRequest, Str
sp.setJwksUri(updateRequest.getJwksURI());
}
// Todo: validate version input. Create a function at app mgt.
sp.setApplicationVersion(applicationVersion);
// Need to create a deep clone, since modifying the fields of the original object,
// will modify the cached SP object.
ServiceProvider clonedSP = cloneServiceProvider(sp);
if (StringUtils.isNotBlank(applicationVersion)) {
sp.setApplicationVersion(applicationVersion);
}
}
if (StringUtils.isNotEmpty(updateRequest.getExtAllowedAudience()) &&
(updateRequest.getExtAllowedAudience().equalsIgnoreCase(ORG_ROLE_AUDIENCE)
|| updateRequest.getExtAllowedAudience().equalsIgnoreCase(APP_ROLE_AUDIENCE))) {
AssociatedRolesConfig associatedRolesConfig = new AssociatedRolesConfig();
associatedRolesConfig.setAllowedAudience(updateRequest.getExtAllowedAudience().toLowerCase());
sp.setAssociatedRolesConfig(associatedRolesConfig);
}
// Need to create a deep clone, since modifying the fields of the original object,
// will modify the cached SP object.
ServiceProvider clonedSP = cloneServiceProvider(sp);
if (StringUtils.isNotEmpty(clientName)) {
clonedSP.setApplicationName(clientName);
updateServiceProvider(clonedSP, tenantDomain, applicationOwner);
}
updateServiceProvider(clonedSP, tenantDomain, applicationOwner);

// Update application
try {
Expand Down Expand Up @@ -413,14 +424,6 @@ public Application updateApplication(ApplicationUpdateRequest updateRequest, Str
appDTO.setPkceSupportPlain(updateRequest.isExtPkceSupportPlain());
appDTO.setBypassClientCredentials(updateRequest.isExtPublicClient());
oAuthAdminService.updateConsumerApplication(appDTO);

if (StringUtils.isNotEmpty(updateRequest.getExtAllowedAudience()) &&
(updateRequest.getExtAllowedAudience().equalsIgnoreCase(ORG_ROLE_AUDIENCE)
|| updateRequest.getExtAllowedAudience().equalsIgnoreCase(APP_ROLE_AUDIENCE))) {
AssociatedRolesConfig associatedRolesConfig = new AssociatedRolesConfig();
associatedRolesConfig.setAllowedAudience(updateRequest.getExtAllowedAudience().toLowerCase());
sp.setAssociatedRolesConfig(associatedRolesConfig);
}
} catch (IdentityOAuthClientException e) {
throw new DCRMClientException(DCRMConstants.ErrorCodes.INVALID_CLIENT_METADATA, e.getMessage(), e);
} catch (IdentityOAuthAdminException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public class DCRMServiceTest {
private String dummyCallbackUrl = "dummyCallbackUrl";
private final String dummyTemplateName = "dummyTemplateName";
private final String dummyBackchannelLogoutUri = "http://backchannel.com/";
private static final String ORG_ROLE_AUDIENCE = "organization";

@Mock
private OAuthConsumerAppDTO dto;
Expand Down Expand Up @@ -1007,6 +1008,7 @@ public void updateApplicationTest(List<String> redirectUri1, String roleAudience
assertEquals(application.getClientId(), dummyConsumerKey);
assertEquals(application.getClientName(), dummyClientName);
assertEquals(application.getClientSecret(), dummyConsumerSecret);
assertEquals(application.getExtAllowedAudience(), roleAudience);
}

@Test
Expand Down
Loading