/**
* Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { LegacyModeInterface } from "@thiva/core/models";
import { I18n } from "@thiva/i18n";
import {
Code,
DocumentationLink,
EmphasizedSegment,
GenericIcon,
Heading,
Popup,
PrimaryButton,
ResourceTab,
ResourceTabPaneInterface,
Text
} from "@thiva/react-components";
import React, { ReactElement } from "react";
import { Trans } from "react-i18next";
import { Divider, Icon, Message } from "semantic-ui-react";
import { ApplicationGeneralTabOverride } from "./components/application-general-tab-overide";
import { MarketingConsentModalWrapper } from "./components/marketing-consent/components";
import { ApplicationConfig, ExtendedFeatureConfigInterface } from "./models";
import { APIAuthorization } from "@thiva/admin.applications.v1/components/api-authorization/api-authorization";
import {
ExtendedClaimInterface,
ExtendedExternalClaimInterface,
SelectedDialectInterface
} from "@thiva/admin.applications.v1/components/settings";
import { ApplicationManagementConstants } from "@thiva/admin.applications.v1/constants";
import {
ApplicationInterface,
ApplicationTabTypes,
SupportedAuthProtocolTypes,
additionalSpProperty
} from "@thiva/admin.applications.v1/models";
import { ClaimManagementConstants } from "@thiva/admin.claims.v1/constants/claim-management-constants";
import { EventPublisher, FeatureConfigInterface } from "@thiva/admin.core.v1";
import { AppConstants } from "@thiva/admin.core.v1/constants";
import { ApplicationRoles } from "@thiva/admin.roles.v2/components/application-roles";
import MobileAppTemplate from "../application-templates/templates/mobile-application/mobile-application.json";
import OIDCWebAppTemplate from "../application-templates/templates/oidc-web-application/oidc-web-application.json";
import SamlWebAppTemplate
from "../application-templates/templates/saml-web-application/saml-web-application.json";
import SinglePageAppTemplate from
"../application-templates/templates/single-page-application/single-page-application.json";
import { getTryItClientId } from "../components/application/utils/try-it-utils";
import { getGettingStartedCardIllustrations } from "../components/getting-started/configs";
function isClaimInterface(
claim: ExtendedClaimInterface | ExtendedExternalClaimInterface
): claim is ExtendedClaimInterface {
if ((claim as ExtendedExternalClaimInterface).mappedLocalClaimURI == undefined) {
return true;
}
return false;
}
const IS_ENTERPRISELOGIN_MANAGEMENT_APP: string = "isEnterpriseLoginManagementApp";
// Relative tab indexes.
const API_AUTHORIZATION_INDEX: number = 4;
const APPLICATION_ROLES_INDEX: number = 4;
const M2M_API_AUTHORIZATION_INDEX: number = 2;
const featureConfig: FeatureConfigInterface = window[ "AppUtils" ].getConfig().ui.features;
/**
* Check whether claims is identity claims or not.
*
* @param claim - claim
* @returns boolean
*/
const isIdentityClaim = (claim: ExtendedClaimInterface | ExtendedExternalClaimInterface): boolean => {
const enableIdentityClaims: boolean = window[ "AppUtils" ]?.getConfig()?.ui?.enableIdentityClaims;
if (enableIdentityClaims) {
return false;
}
const identityRegex: RegExp = new RegExp("wso2.org/claims/identity");
if (isClaimInterface(claim)) {
return identityRegex.test(claim.claimURI);
}
return identityRegex.test(claim.mappedLocalClaimURI);
};
export const applicationConfig: ApplicationConfig = {
advancedConfigurations: {
showEnableAuthorization: true,
showFapiFeatureStatusChip: false,
showMtlsAliases: false,
showMyAccount: true,
showMyAccountStatus: false,
showReturnAuthenticatedIdPs: true,
showSaaS: true
},
allowedGrantTypes: {
// single page app template
[ "6a90e4b0-fbff-42d7-bfde-1efd98f07cd7" ]: [
ApplicationManagementConstants.AUTHORIZATION_CODE_GRANT,
ApplicationManagementConstants.REFRESH_TOKEN_GRANT,
ApplicationManagementConstants.IMPLICIT_GRANT,
ApplicationManagementConstants.ORGANIZATION_SWITCH_GRANT
],
// oidc traditional web app template
[ "b9c5e11e-fc78-484b-9bec-015d247561b8" ]: [
ApplicationManagementConstants.AUTHORIZATION_CODE_GRANT,
ApplicationManagementConstants.IMPLICIT_GRANT,
ApplicationManagementConstants.CLIENT_CREDENTIALS_GRANT,
ApplicationManagementConstants.REFRESH_TOKEN_GRANT,
ApplicationManagementConstants.ORGANIZATION_SWITCH_GRANT,
ApplicationManagementConstants.OAUTH2_TOKEN_EXCHANGE
],
// oidc standard app template
[ "custom-application" ]: [
ApplicationManagementConstants.AUTHORIZATION_CODE_GRANT,
ApplicationManagementConstants.IMPLICIT_GRANT,
ApplicationManagementConstants.PASSWORD,
ApplicationManagementConstants.CLIENT_CREDENTIALS_GRANT,
ApplicationManagementConstants.REFRESH_TOKEN_GRANT,
ApplicationManagementConstants.ORGANIZATION_SWITCH_GRANT,
ApplicationManagementConstants.DEVICE_GRANT,
ApplicationManagementConstants.OAUTH2_TOKEN_EXCHANGE,
ApplicationManagementConstants.SAML2_BEARER,
ApplicationManagementConstants.JWT_BEARER,
ApplicationManagementConstants.IWA_NTLM
],
[ "m2m-application" ]: [
ApplicationManagementConstants.CLIENT_CREDENTIALS_GRANT
],
[ "mobile-application" ]: [
ApplicationManagementConstants.AUTHORIZATION_CODE_GRANT,
ApplicationManagementConstants.REFRESH_TOKEN_GRANT,
ApplicationManagementConstants.IMPLICIT_GRANT,
ApplicationManagementConstants.PASSWORD,
ApplicationManagementConstants.DEVICE_GRANT,
ApplicationManagementConstants.ORGANIZATION_SWITCH_GRANT,
ApplicationManagementConstants.OAUTH2_TOKEN_EXCHANGE
]
},
attributeSettings: {
advancedAttributeSettings: {
isLinkedAccountsEnabled: (templateId: string): boolean => {
const allowedTemplates: string[] = [
ApplicationManagementConstants.CUSTOM_APPLICATION_PASSIVE_STS,
ApplicationManagementConstants.CUSTOM_APPLICATION_SAML,
ApplicationManagementConstants.TRADITIONAL_WEB_APPLICATION_SAML,
ApplicationManagementConstants.MOBILE,
ApplicationManagementConstants.CUSTOM_APPLICATION_OIDC,
ApplicationManagementConstants.TRADITIONAL_WEB_APPLICATION_OIDC,
ApplicationManagementConstants.SPA_APP_TEMPLATE_ID
];
return allowedTemplates.includes(templateId);
},
showIncludeTenantDomain: true,
showIncludeUserstoreDomainRole: true,
showIncludeUserstoreDomainSubject: true,
showMandateLinkedLocalAccount: false,
showRoleAttribute: true,
showRoleMapping: true,
showSubjectAttribute: true,
showValidateLinkedLocalAccount: true
},
attributeSelection: {
getClaims: (claims: ExtendedClaimInterface[]): ExtendedClaimInterface[] => {
return claims.filter((claim: ExtendedClaimInterface) => isIdentityClaim(claim) == false);
},
getExternalClaims: (claims: ExtendedExternalClaimInterface[]): ExtendedExternalClaimInterface[] => {
return claims.filter((claim: ExtendedExternalClaimInterface) => isIdentityClaim(claim) == false);
},
showAttributePlaceholderTitle: false,
showShareAttributesHint: (selectedDialect: SelectedDialectInterface): boolean => {
return selectedDialect.id === ClaimManagementConstants.ATTRIBUTE_DIALECT_IDS.get("OIDC");
}
},
makeSubjectMandatory: true,
roleMapping: true
},
customApplication: {
allowedProtocolTypes: [
SupportedAuthProtocolTypes.OAUTH2_OIDC,
SupportedAuthProtocolTypes.SAML,
SupportedAuthProtocolTypes.WS_FEDERATION
],
defaultTabIndex: 1
},
editApplication: {
extendTabs: false,
getActions: (clientId: string, tenant: string, testId: string) => {
const asgardeoLoginPlaygroundURL: string = window[ "AppUtils" ]?.getConfig()?.extensions?.asgardeoTryItURL;
return (
clientId === getTryItClientId(tenant)
? (
You will need a user account to log in to the applications.
{ " " }
Do not have a user account?{ " " } {
window.open(AppConstants.getClientOrigin()
+ AppConstants.getPaths().get("USERS"),
"",
"noopener");
} }
className="external-link link pointing primary"
>Create Account
Username & Password
, Social Login or Passkey
is present in a previous step.