wso2 / product-is

Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
746 stars 724 forks source link

Consider tenant ID in retrieving applicaiton claim mappings. #5206

Open Pushpalanka opened 5 years ago

Pushpalanka commented 5 years ago

The query we have at [1] SELECT IDP_CLAIM, SP_CLAIM, IS_REQUESTED, IS_MANDATORY, DEFAULT_VALUE FROM SP_CLAIM_MAPPING WHERE APP_ID = (SELECT ID FROM SP_APP WHERE APP_NAME = '?') AND TENANT_ID = ?;

Seems to break when two tenants create applications with the same name. We do have the unique key constraint in place as below, ALTER TABLE SP_APP ADD CONSTRAINT APPLICATION_NAME_CONSTRAINT UNIQUE(APP_NAME, TENANT_ID); Hence we will be able to simply fix this correcting the previous query as below.

SELECT IDP_CLAIM, SP_CLAIM, IS_REQUESTED, IS_MANDATORY, DEFAULT_VALUE FROM SP_CLAIM_MAPPING WHERE APP_ID = (SELECT ID FROM SP_APP WHERE APP_NAME = '?' AND TENANT_ID = ?);

[1] - https://github.com/wso2/carbon-identity-framework/blob/master/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtDBQueries.java#L122

mefarazath commented 5 years ago

@thushaaanthan Hope you have opened a PR for master branch as well.