Skip to content

Commit

Permalink
Merge pull request #3866 from DedunuKarunarathne/master
Browse files Browse the repository at this point in the history
Fix role based filtering on query result of DSS not working
  • Loading branch information
DedunuKarunarathne authored Jan 10, 2025
2 parents 162c499 + de2c10b commit 19cae00
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@
<groupId>org.wso2.ei</groupId>
<artifactId>org.wso2.micro.integrator.dataservices.sql.driver</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.ei</groupId>
<artifactId>org.wso2.micro.integrator.security</artifactId>
<exclusions>
<exclusion>
<groupId> org.apache.synapse</groupId>
<artifactId>synapse-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.orbit.org.webharvest</groupId>
<artifactId>webharvest-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import org.wso2.micro.integrator.dataservices.core.engine.ParamValue;
import org.wso2.micro.integrator.dataservices.core.internal.DataServicesDSComponent;
import org.wso2.micro.integrator.ndatasource.core.utils.DataSourceUtils;
import org.wso2.micro.integrator.security.MicroIntegratorSecurityUtils;
import org.wso2.micro.integrator.security.user.api.UserStoreException;
import org.wso2.securevault.SecretResolver;
import org.wso2.securevault.SecretResolverFactory;

Expand Down Expand Up @@ -326,37 +328,11 @@ public static String getCurrentContextUsername(DataService dataService) {
* @throws DataServiceFault
*/
public static String[] getUserRoles(String username) throws DataServiceFault {
// RealmService realmService = DataServicesDSComponent.getRealmService();
// RegistryService registryService = DataServicesDSComponent.getRegistryService();
// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
// try {
// if (tenantId < MultitenantConstants.SUPER_TENANT_ID) {
// tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
// }
// if (tenantId < MultitenantConstants.SUPER_TENANT_ID) {
// /* the tenant doesn't exist. */
// log.error("The tenant doesn't exist. Tenant domain:" + tenantDomain);
// throw new DataServiceFault("Access Denied. You are not authorized.");
// }
// if (tenantId != MultitenantConstants.SUPER_TENANT_ID){ //tenant space users can't access super tenant
// username = MultitenantUtils.getTenantAwareUsername(username);
// }
// if (!realmService.getTenantManager().isTenantActive(tenantId)) {
// /* the tenant is not active. */
// log.error("The tenant is not active. Tenant domain:" + tenantDomain);
// throw new DataServiceFault("The tenant is not active. Tenant domain:"
// + tenantDomain);
// }
// UserRealm realm = registryService.getUserRealm(tenantId);
// String roles[] = realm.getUserStoreManager().getRoleListOfUser(username);
// return roles;
// } catch (Exception e) {
// String msg = "Error in retrieving the realm for the tenant id: " + tenantId
// + ", username: " + username + ". " + e.getMessage();
// throw new DataServiceFault(msg);
// }
return new String[0];
try {
return MicroIntegratorSecurityUtils.getUserStoreManager().getRoleListOfUser(username);
} catch (UserStoreException e) {
throw new DataServiceFault(e, "Error while getting the user role");
}
}


Expand Down

0 comments on commit 19cae00

Please sign in to comment.