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 for to block getting same app response when its created previuosly. #12056

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -200,11 +200,22 @@ public Response register(RegistrationProfile profile) {
(RestApiConstants.STATUS_BAD_REQUEST_MESSAGE_DEFAULT, 500L, errorMsg);
response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).
entity(errorDTO).build();
} else {
} else if ((authUserName.equals(returnedAPP.getAppOwner())) ||
(isUserSuperAdmin(authUserName) && owner != null && owner.equals(returnedAPP.getAppOwner()))) {
// Permitting only the owner of the application to create/get the OAuth app and admin user to
// create/get the app info if the created app owner equals the payload app owner.
if (log.isDebugEnabled()) {
log.debug("OAuth app " + profile.getClientName() + " creation successful.");
}
response = Response.status(Response.Status.OK).entity(returnedAPP).build();
} else {
String errMsg = "Access is forbidden to the application";
if (log.isDebugEnabled()) {
log.debug("OAuth app owner: " + returnedAPP.getAppOwner() + " is different from payload " +
"owner: " + owner + " and " + errMsg);
}
errorDTO = RestApiUtil.getErrorDTO(RestApiConstants.STATUS_FORBIDDEN_MESSAGE_DEFAULT, 403L, errMsg);
response = Response.status(Response.Status.FORBIDDEN).entity(errorDTO).build();
}
} else {
String errorMsg = "Logged in user '" + authUserName + "' and application owner '" +
Expand Down Expand Up @@ -262,8 +273,9 @@ private OAuthApplicationInfo getExistingApp(String applicationName, boolean saas

appToReturn = this.fromAppDTOToApplicationInfo(consumerAppDTO.getOauthConsumerKey(),
consumerAppDTO.getApplicationName(), consumerAppDTO.getCallbackUrl(),
consumerAppDTO.getOauthConsumerSecret(), saasApp, null, consumerAppDTO.getTokenType(), valueMap);

consumerAppDTO.getOauthConsumerSecret(), saasApp, MultitenantUtils
Copy link
Contributor

@HiranyaKavishani HiranyaKavishani Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail when create oauth app using tenant user ==> wso2/api-manager#2064

.getTenantAwareUsername(consumerAppDTO.getUsername()), consumerAppDTO.getTokenType(),
valueMap);
} catch (IdentityOAuthAdminException e) {
log.error("error occurred while trying to get OAuth Application data", e);
}
Expand Down