Skip to content

Commit f814868

Browse files
Merge pull request wso2#9947 from wso2/sync-pr-9843-to-next
[Sync][master -> next][wso2#9843]: Hide enable enhanced org authentication toggle in my account settings update view in console
2 parents 620792f + 49a3b75 commit f814868

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

.changeset/odd-rice-vanish.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@wso2is/admin.applications.v1": patch
3+
"@wso2is/identity-apps-core": patch
4+
"@wso2is/console": patch
5+
---
6+
7+
Hide enable enhanced org authentication toggle in my account and add backend validations for system apps

features/admin.applications.v1/components/settings/shared-access.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export const SharedAccess: FunctionComponent<SharedAccessPropsInterface> = (
8585
const isEnhancedOrganizationAuthenticationFeatureEnabled: boolean = useSelector((state: AppState) =>
8686
state?.config?.ui?.isEnhancedOrganizationAuthenticationFeatureEnabled);
8787

88+
const isMyAccount: boolean =
89+
ApplicationManagementConstants.MY_ACCOUNT_CLIENT_ID === application?.clientId ||
90+
ApplicationManagementConstants.MY_ACCOUNT_APP_NAME === application?.name;
91+
8892
const statusToi18nKeyMap: Map<OperationStatus, { alertLevel: AlertLevels, i18nKey: string }> =
8993
new Map<OperationStatus, { alertLevel: AlertLevels, i18nKey: string }>([
9094
[ OperationStatus.SUCCESS, { alertLevel: AlertLevels.SUCCESS, i18nKey: "success" } ],
@@ -155,7 +159,7 @@ export const SharedAccess: FunctionComponent<SharedAccessPropsInterface> = (
155159
)
156160
}
157161
</EmphasizedSegment>
158-
{ isEnhancedOrganizationAuthenticationFeatureEnabled && (
162+
{ isEnhancedOrganizationAuthenticationFeatureEnabled && !isMyAccount && (
159163
<EnhancedOrganizationLoginToggle
160164
appId={ application.id }
161165
isEnabled={ application.enhancedOrgAuthenticationEnabled ?? false }

identity-apps-core/components/org.wso2.identity.apps.common/src/main/java/org/wso2/identity/apps/common/listner/AppPortalApplicationMgtListener.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@
2020

2121
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementClientException;
2222
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
23+
import org.wso2.carbon.identity.application.common.model.InboundAuthenticationConfig;
24+
import org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig;
2325
import org.wso2.carbon.identity.application.common.model.ServiceProvider;
2426
import org.wso2.carbon.identity.application.common.util.IdentityApplicationManagementUtil;
2527
import org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener;
28+
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
2629
import org.wso2.carbon.identity.oauth.Error;
2730
import org.wso2.identity.apps.common.internal.AppsCommonDataHolder;
2831

32+
import java.util.Arrays;
33+
import java.util.Optional;
2934
import java.util.Set;
3035

36+
import static org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols.OAUTH2;
37+
3138
/**
3239
* App portal application management listener.
3340
*/
@@ -64,7 +71,18 @@ public boolean isEnable() {
6471
public boolean doPreUpdateApplication(ServiceProvider serviceProvider, String tenantDomain, String userName)
6572
throws IdentityApplicationManagementException {
6673

67-
if (!isEnable() || IdentityApplicationManagementUtil.getAllowUpdateSystemApplicationThreadLocal()) {
74+
if (!isEnable()) {
75+
return true;
76+
}
77+
78+
Optional<String> clientId = getOAuth2ClientId(serviceProvider);
79+
if (clientId.isPresent() && IdentityTenantUtil.isSystemApplication(tenantDomain, clientId.get()) &&
80+
serviceProvider.isEnhancedOrganizationAuthenticationEnabled()) {
81+
throw new IdentityApplicationManagementClientException(Error.INVALID_UPDATE.getErrorCode(),
82+
"Enabling enhanced organization authentication is not allowed for system applications.");
83+
}
84+
85+
if (IdentityApplicationManagementUtil.getAllowUpdateSystemApplicationThreadLocal()) {
6886
return true;
6987
}
7088

@@ -93,6 +111,17 @@ public boolean doPreDeleteApplication(String applicationName, String tenantDomai
93111
"Deletion of system applications are not allowed. Application name: " + applicationName);
94112
}
95113

114+
private Optional<String> getOAuth2ClientId(ServiceProvider serviceProvider) {
115+
116+
return Optional.ofNullable(serviceProvider.getInboundAuthenticationConfig())
117+
.map(InboundAuthenticationConfig::getInboundAuthenticationRequestConfigs)
118+
.map(Arrays::stream)
119+
.flatMap(stream -> stream
120+
.filter(cfg -> OAUTH2.equals(cfg.getInboundAuthType()))
121+
.findFirst())
122+
.map(InboundAuthenticationRequestConfig::getInboundAuthKey);
123+
}
124+
96125
private ServiceProvider getApplicationByResourceId(String resourceId, String tenantDomain)
97126
throws IdentityApplicationManagementException {
98127

identity-apps-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@
804804
<carbon.extension.identity.authenticator.version>3.0.0</carbon.extension.identity.authenticator.version>
805805
<org.wso2.carbon.identity.association.account>5.1.5</org.wso2.carbon.identity.association.account>
806806
<identity.extension.utils>1.0.8</identity.extension.utils>
807-
<carbon.identity.framework.version>7.10.32</carbon.identity.framework.version>
807+
<carbon.identity.framework.version>7.10.68</carbon.identity.framework.version>
808808
<carbon.identity.framework.imp.pkg.version.range>[5.0.0, 8.0.0)</carbon.identity.framework.imp.pkg.version.range>
809809
<identity.organization.management.core.service.version>1.0.77
810810
</identity.organization.management.core.service.version>

0 commit comments

Comments
 (0)