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

Modify the core to support removing the necessity of having role_org-application association #5619

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

DMHP
Copy link
Contributor

@DMHP DMHP commented Apr 8, 2024

Proposed changes in this pull request

Modify the core to support removing the necessity of having role_org-application association

When should this PR be merged

Immediately

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Hasanthi Dissanayake seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment on lines 244 to 246
* Get application uuid.
* @return uuid application uuid
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Get application uuid.
* @return uuid application uuid
* Get application uuid.
*
* @return uuid application uuid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Check formatting in other places as well

@@ -78,6 +78,15 @@ public class ApplicationMgtDBQueries {
"TENANT_ID = ? AND APP_NAME != ? ORDER BY ID DESC";
public static final String LOAD_APP_NAMES_BY_TENANT_AND_APP_NAME = "SELECT ID, APP_NAME, DESCRIPTION FROM SP_APP " +
"WHERE TENANT_ID = ? AND APP_NAME != ? AND (%s) ORDER BY ID DESC";

public static final String LOAD_APP_IDS_BY_SP_PROPERTY_H2 = "SELECT SP_APP.UUID FROM SP_APP JOIN " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static final String LOAD_APP_IDS_BY_SP_PROPERTY_H2 = "SELECT SP_APP.UUID FROM SP_APP JOIN " +
public static final String LOAD_APP_IDS_BY_SP_PROPERTY_H2 = "SELECT SP_APP.UUID FROM SP_APP JOIN " +

"SP_METADATA ON SP_APP.ID = SP_METADATA.SP_ID WHERE SP_METADATA.NAME=? and " +
"SP_METADATA.`VALUE`=? AND SP_METADATA.TENANT_ID = ?";

public static final String LOAD_APP_IDS_BY_SP_PROPERTY = "SELECT SP_APP.UUID FROM SP_APP JOIN " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static final String LOAD_APP_IDS_BY_SP_PROPERTY = "SELECT SP_APP.UUID FROM SP_APP JOIN " +
public static final String LOAD_APP_IDS_BY_SP_PROPERTY = "SELECT SP_APP.UUID FROM SP_APP JOIN " +

* @param key Name of the sp metadata property key
* @param value Value of the sp metadata property
* @return ApplicationBasicInfo containing the basic app information
* @throws IdentityApplicationManagementException
Copy link
Contributor

Choose a reason for hiding this comment

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

complete the exception description

@@ -193,6 +195,8 @@ public class ApplicationDAOImpl extends AbstractApplicationDAOImpl implements Pa

private static final String SP_PROPERTY_NAME_CERTIFICATE = "CERTIFICATE";
private static final String APPLICATION_NAME_CONSTRAINT = "APPLICATION_NAME_CONSTRAINT";
public static final String AUDIENCE_EQ_ORGANIZATION = "audience eq organization";
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we build this filter value by combining existing constants for audience, eq and organization separately

Comment on lines 2277 to 2281
List<RoleBasicInfo> listOfAllRoles = roleManagementServiceV2.getRoles(AUDIENCE_EQ_ORGANIZATION,
0, 0, null, null, tenantDomain);
List<String> roleIds = listOfAllRoles.stream().map(RoleBasicInfo::getId).collect(Collectors.toList());
associatedRolesConfig.setRoles(buildAssociatedRolesWithRoleName(roleIds, tenantDomain));
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we returning all organization audienced roles as the associated roles, if the app is using organization audienced roles?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

Comment on lines 3781 to 3782
* @return
* @throws IdentityApplicationManagementException
Copy link
Contributor

Choose a reason for hiding this comment

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

complete


int tenantID = CarbonContext.getThreadLocalCarbonContext().getTenantId();
if (log.isDebugEnabled()) {
log.debug("Getting the all applications for the tenant: " + tenantID);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.debug("Getting the all applications for the tenant: " + tenantID);
log.debug(String.format("Getting the all applications matching to property: %s value equals to %s in the tenant: %d", key, value, tenantID);

ResultSet appNameResultSet = null;
ArrayList<ApplicationBasicInfo> appInfo = new ArrayList<ApplicationBasicInfo>();

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we use try with resource, making connection and preparedStatement resources which auto closable at the end of usage?

@@ -78,6 +78,15 @@ public class ApplicationMgtDBQueries {
"TENANT_ID = ? AND APP_NAME != ? ORDER BY ID DESC";
public static final String LOAD_APP_NAMES_BY_TENANT_AND_APP_NAME = "SELECT ID, APP_NAME, DESCRIPTION FROM SP_APP " +
"WHERE TENANT_ID = ? AND APP_NAME != ? AND (%s) ORDER BY ID DESC";

public static final String LOAD_APP_IDS_BY_SP_PROPERTY_H2 = "SELECT SP_APP.UUID FROM SP_APP JOIN " +
"SP_METADATA ON SP_APP.ID = SP_METADATA.SP_ID WHERE SP_METADATA.NAME=? and " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"SP_METADATA ON SP_APP.ID = SP_METADATA.SP_ID WHERE SP_METADATA.NAME=? and " +
"SP_METADATA ON SP_APP.ID = SP_METADATA.SP_ID WHERE SP_METADATA.NAME=? and " +

"SP_METADATA.`VALUE`=? AND SP_METADATA.TENANT_ID = ?";

public static final String LOAD_APP_IDS_BY_SP_PROPERTY = "SELECT SP_APP.UUID FROM SP_APP JOIN " +
"SP_METADATA ON SP_APP.ID = SP_METADATA.SP_ID WHERE SP_METADATA.NAME=? and " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"SP_METADATA ON SP_APP.ID = SP_METADATA.SP_ID WHERE SP_METADATA.NAME=? and " +
"SP_METADATA ON SP_APP.ID = SP_METADATA.SP_ID WHERE SP_METADATA.NAME=? and " +

@DMHP DMHP force-pushed the role_org branch 4 times, most recently from a333a8b to 9ae4f20 Compare April 8, 2024 17:32
shashimalcse
shashimalcse previously approved these changes Apr 11, 2024
RoleManagementService roleManagementService = holder.getRoleManagementServiceV2();
try {
if (roleManagementService != null) {
List<RoleBasicInfo> listOfAllRoles = roleManagementService.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
List<RoleBasicInfo> listOfAllRoles = roleManagementService.
List<RoleBasicInfo> listOfAllOrgRoles = roleManagementService.

try {
if (roleManagementService != null) {
List<RoleBasicInfo> listOfAllRoles = roleManagementService.
getRoles(RoleConstants.AUDIENCE + SPACE + RoleConstants.EQ + SPACE +
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any max limit defined in role mgt service when request to get all roles matching to a filter?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems this is fixed in the same PR. Hence ignore the comment

*
* @param key Name of the sp metadata property key
* @param value Value of the sp metadata property value
* @return
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @return
* @return Filtered applications' basic information.

@DMHP DMHP merged commit 8fd991b into wso2:master Apr 16, 2024
1 of 2 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants