Skip to content

Commit

Permalink
Merge pull request #12191 from GihanAyesh/apikeyrevocation
Browse files Browse the repository at this point in the history
Check for multi groups
  • Loading branch information
GihanAyesh authored Dec 1, 2023
2 parents bb82dad + a0005f2 commit 85831f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@ public Response applicationsApplicationIdApiKeysKeyTypeRevokePost(String applica
new String(Base64.getUrlDecoder().decode(splitToken[1])));
org.json.JSONObject appInfo = decodedBody.getJSONObject(APIConstants.JwtTokenConstants.APPLICATION);
if (appInfo != null && application != null) {
if (RestAPIStoreUtils.isUserOwnerOfApplication(application)) {
if (RestAPIStoreUtils.isUserOwnerOfApplication(application)
|| RestAPIStoreUtils.isApplicationSharedtoUser(application)) {
String appUuid = appInfo.getString(APIConstants.JwtTokenConstants.APPLICATION_UUID);
if (applicationId.equals(appUuid)) {
long expiryTime = Long.MAX_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,29 @@ public static boolean isUserOwnerOfApplication(Application application) {
return false;
}

/**
* check whether an application is shared with the current logged-in user
*
* @param application Application object
* @return true if the application is shared with the current logged-in user
*/
public static boolean isApplicationSharedtoUser(Application application) {
boolean multiGroupAppSharingEnabled = APIUtil.isMultiGroupAppSharingEnabled();
if (multiGroupAppSharingEnabled) {
String groupId = application.getGroupId();
String userGroupId = RestApiUtil.getLoggedInUserGroupId();
if (groupId != null && userGroupId != null) {
String[] grpIdArray = groupId.split(",");
for (String id : grpIdArray) {
if (id.equals(userGroupId)) {
return true;
}
}
}
}
return false;
}

/**
* Check whether the specified API exists and the current logged in user has access to it.
* <p>
Expand Down

0 comments on commit 85831f9

Please sign in to comment.