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

Allow application creation in sub organization level #409

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -132,15 +132,22 @@ public boolean doPreCreateApplication(ServiceProvider serviceProvider, String te
throws IdentityApplicationManagementException {

try {
String organizationId = getOrganizationManager().resolveOrganizationId(tenantDomain);
int organizationDepthInHierarchy =
getOrganizationManager().getOrganizationDepthInHierarchy(organizationId);
if (isSubOrganization(organizationDepthInHierarchy) &&
!isSharedAppFromInternalProcess(serviceProvider, tenantDomain)) {
throw new IdentityApplicationManagementClientException(
ERROR_CODE_SUB_ORG_CANNOT_CREATE_APP.getCode(),
ERROR_CODE_SUB_ORG_CANNOT_CREATE_APP.getMessage());
boolean isFragmentApp = serviceProvider.getSpProperties() != null &&
Arrays.stream(serviceProvider.getSpProperties()).anyMatch(
property -> IS_FRAGMENT_APP.equals(property.getName()) &&
Boolean.parseBoolean(property.getValue()));
if (isFragmentApp) {
String organizationId = getOrganizationManager().resolveOrganizationId(tenantDomain);
int organizationDepthInHierarchy =
getOrganizationManager().getOrganizationDepthInHierarchy(organizationId);
if (isSubOrganization(organizationDepthInHierarchy) &&
!isSharedAppFromSharingProcess(serviceProvider, tenantDomain)) {
throw new IdentityApplicationManagementClientException(
ERROR_CODE_SUB_ORG_CANNOT_CREATE_APP.getCode(),
ERROR_CODE_SUB_ORG_CANNOT_CREATE_APP.getMessage());
}
}
return true;
} catch (OrganizationManagementClientException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Organization not found for the tenant: " + tenantDomain);
Expand Down Expand Up @@ -584,7 +591,7 @@ private ClaimMapping[] addApplicationRolesToFilteredClaimMappings(ClaimMapping[]
* @param tenantDomain The tenant domain which the service provider app is belongs to.
* @return True if app is shared by an internal process of Asgardeo for sharing apps to sub organizations.
*/
private boolean isSharedAppFromInternalProcess(ServiceProvider serviceProvider, String tenantDomain) {
private boolean isSharedAppFromSharingProcess(ServiceProvider serviceProvider, String tenantDomain) {

return serviceProvider.getSpProperties() != null && Arrays.stream(serviceProvider.getSpProperties())
.anyMatch(property -> IS_FRAGMENT_APP.equals(property.getName()) &&
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@
<properties>

<!-- Carbon kernel version -->
<carbon.kernel.version>4.9.17</carbon.kernel.version>
<carbon.kernel.version>4.10.26</carbon.kernel.version>
<carbon.kernel.package.import.version.range>[4.7.0, 5.0.0)</carbon.kernel.package.import.version.range>
<carbon.kernel.feature.version>4.6.0</carbon.kernel.feature.version>

Expand Down
Loading