Skip to content

[WIP] Resolve circular dependencies #8051

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
15 changes: 9 additions & 6 deletions apps/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@wso2is/admin.alternative-login-identifier.v1": "^1.5.203",
"@wso2is/admin.api-resources.v1": "^2.25.203",
"@wso2is/admin.api-resources.v2": "^2.25.203",
"@wso2is/admin.application-templates.v1": "^1.5.2",
"@wso2is/admin.applications.v1": "^2.34.3",
"@wso2is/admin.authentication.v1": "^2.25.204",
"@wso2is/admin.authorization.v1": "^2.25.88",
Expand All @@ -64,36 +65,40 @@
"@wso2is/admin.email-and-sms.v1": "^2.25.203",
"@wso2is/admin.email-management.v1": "^2.25.203",
"@wso2is/admin.email-providers.v1": "^2.25.203",
"@wso2is/admin.email-templates.v1": "^2.25.203",
"@wso2is/admin.extensions.v1": "^2.37.3",
"@wso2is/admin.feature-gate.v1": "^1.6.1",
"@wso2is/admin.groups.v1": "^2.27.117",
"@wso2is/admin.home.v1": "^1.7.2",
"@wso2is/admin.identity-verification-providers.v1": "^2.27.203",
"@wso2is/admin.impersonation.v1": "^1.6.203",
"@wso2is/admin.logs.v1": "^1.6.2",
"@wso2is/admin.oidc-scopes.v1": "^2.25.203",
"@wso2is/admin.org-insights.v1": "^2.25.203",
"@wso2is/admin.organization-discovery.v1": "^2.25.203",
"@wso2is/admin.organizations.v1": "^2.26.203",
"@wso2is/admin.policy-administration.v1": "^1.0.120",
"@wso2is/admin.private-key-jwt.v1": "^2.25.203",
"@wso2is/admin.push-providers.v1": "^1.0.92",
"@wso2is/admin.registration-flow-builder.v1": "^0.5.6",
"@wso2is/admin.remote-repository-configuration.v1": "^2.25.203",
"@wso2is/admin.impersonation.v1": "^1.6.203",
"@wso2is/admin.policy-administration.v1": "^1.0.120",
"@wso2is/admin.remote-userstores.v1": "^1.7.159",
"@wso2is/admin.roles.v1": "^2.25.203",
"@wso2is/admin.roles.v2": "^2.27.149",
"@wso2is/admin.rules.v1": "^0.4.19",
"@wso2is/admin.saml2-configuration.v1": "^2.25.204",
"@wso2is/admin.secrets.v1": "^2.25.203",
"@wso2is/admin.server-configurations.v1": "^2.34.2",
"@wso2is/admin.session-management.v1": "^2.25.203",
"@wso2is/admin.sms-providers.v1": "^2.25.203",
"@wso2is/admin.sms-templates.v1": "^1.0.202",
"@wso2is/admin.subscription.v1": "^1.5.203",
"@wso2is/admin.template-core.v1": "^1.5.157",
"@wso2is/admin.tenants.v1": "^2.29.9",
"@wso2is/admin.username-validation.v1": "^1.5.203",
"@wso2is/admin.users.v1": "^2.30.124",
"@wso2is/admin.validation.v1": "^2.27.142",
"@wso2is/admin.userstores.v1": "^2.27.29",
"@wso2is/admin.validation.v1": "^2.27.142",
"@wso2is/admin.workflow-approvals.v1": "^2.25.203",
"@wso2is/admin.wsfed-configuration.v1": "^2.25.203",
"@wso2is/common.ui.v1": "^0.2.0",
Expand Down Expand Up @@ -141,9 +146,7 @@
"slashes": "^2.0.2",
"styled-components": "^4.4.1",
"swr": "^2.0.0",
"uuid": "^8.3.0",
"@wso2is/admin.application-templates.v1": "^1.5.2",
"@wso2is/admin.template-core.v1": "^1.5.157"
"uuid": "^8.3.0"
},
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
Expand Down
7 changes: 4 additions & 3 deletions apps/console/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2023-2025, 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
Expand Down Expand Up @@ -71,6 +71,7 @@ import { Redirect, Route, RouteComponentProps, Router, Switch } from "react-rout
import { Dispatch } from "redux";
import "moment/locale/si";
import "moment/locale/fr";
import { getServiceResourceEndpoints } from "./configs/endpoints";
import { getBaseRoutes } from "./configs/routes";
import DecoratedApp from "./decorated-app";
import "./app.scss";
Expand Down Expand Up @@ -129,9 +130,9 @@ export const App: FunctionComponent<Record<string, never>> = (): ReactElement =>
* Set the deployment configs in redux state.
*/
useEffect(() => {
dispatch(setServiceResourceEndpoints<ServiceResourceEndpointsInterface>(Config.getServiceResourceEndpoints()));
dispatch(setServiceResourceEndpoints<ServiceResourceEndpointsInterface>(getServiceResourceEndpoints()));
dispatch(setI18nConfigs<I18nModuleOptionsInterface>(Config.getI18nConfig()));
setResourceEndpoints(Config.getServiceResourceEndpoints() as any);
setResourceEndpoints(getServiceResourceEndpoints() as any);
}, [ AppConstants.getTenantQualifiedAppBasename() ]);

/**
Expand Down
182 changes: 182 additions & 0 deletions apps/console/src/configs/endpoints.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/**
* Copyright (c) 2025, 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 { getActionsResourceEndpoints } from "@wso2is/admin.actions.v1/configs/endpoints";
import { getAdministratorsResourceEndpoints } from "@wso2is/admin.administrators.v1/config/endpoints";
import { getAPIResourceEndpoints } from "@wso2is/admin.api-resources.v2/configs/endpoint";
import { getApplicationTemplatesResourcesEndpoints } from "@wso2is/admin.application-templates.v1/configs/endpoints";
import { getApplicationsResourceEndpoints } from "@wso2is/admin.applications.v1/configs/endpoints";
import { getBrandingResourceEndpoints } from "@wso2is/admin.branding.v1/configs/endpoints";
import { getCertificatesResourceEndpoints } from "@wso2is/admin.certificates.v1/configs/endpoints";
import { getClaimResourceEndpoints } from "@wso2is/admin.claims.v1/configs/endpoints";
import { getConnectionResourceEndpoints } from "@wso2is/admin.connections.v1/configs/endpoints";
import { DeploymentConfigInterface, ServiceResourceEndpointsInterface } from "@wso2is/admin.core.v1/models/config";
import { store } from "@wso2is/admin.core.v1/store";
import { getEmailTemplatesResourceEndpoints } from "@wso2is/admin.email-templates.v1/configs/endpoints";
import { getExtendedFeatureResourceEndpoints } from "@wso2is/admin.extensions.v1/configs/endpoints";
import { getFeatureGateResourceEndpoints } from "@wso2is/admin.feature-gate.v1/configs/endpoints";
import { getGroupsResourceEndpoints } from "@wso2is/admin.groups.v1/configs/endpoints";
import { getIDVPResourceEndpoints } from "@wso2is/admin.identity-verification-providers.v1/configs/endpoints";
import { getRemoteLoggingEndpoints } from "@wso2is/admin.logs.v1/configs/endpoints";
import { getScopesResourceEndpoints } from "@wso2is/admin.oidc-scopes.v1/configs/endpoints";
import { getInsightsResourceEndpoints } from "@wso2is/admin.org-insights.v1/config/org-insights";
import { getOrganizationsResourceEndpoints } from "@wso2is/admin.organizations.v1/configs/endpoints";
import { OrganizationUtils } from "@wso2is/admin.organizations.v1/utils/organization";
import { getPolicyAdministrationResourceEndpoints } from "@wso2is/admin.policy-administration.v1/configs/endpoints";
import {
getPushProviderResourceEndpoints,
getPushProviderTemplateEndpoints
} from "@wso2is/admin.push-providers.v1/configs/endpoints";
import {
getRegistrationFlowBuilderResourceEndpoints
} from "@wso2is/admin.registration-flow-builder.v1/config/endpoints";
import {
getRemoteFetchConfigResourceEndpoints
} from "@wso2is/admin.remote-repository-configuration.v1/configs/endpoints";
import { getRolesResourceEndpoints } from "@wso2is/admin.roles.v2/configs/endpoints";
import { getRulesEndpoints } from "@wso2is/admin.rules.v1/configs/endpoints";
import { getSecretsManagementEndpoints } from "@wso2is/admin.secrets.v1/configs/endpoints";
import { getServerConfigurationsResourceEndpoints } from "@wso2is/admin.server-configurations.v1/configs/endpoints";
import { getSmsTemplateResourceEndpoints } from "@wso2is/admin.sms-templates.v1/configs/endpoints";
import { getExtensionTemplatesEndpoints } from "@wso2is/admin.template-core.v1/configs/endpoints";
import { getTenantResourceEndpoints } from "@wso2is/admin.tenants.v1/configs/endpoints";
import { getUsersResourceEndpoints } from "@wso2is/admin.users.v1/configs/endpoints";
import { getUserstoreResourceEndpoints } from "@wso2is/admin.userstores.v1/configs/endpoints";
import { getValidationServiceEndpoints } from "@wso2is/admin.validation.v1/configs/endpoints";
import { getApprovalsResourceEndpoints } from "@wso2is/admin.workflow-approvals.v1/configs/endpoints";

// TODO: Revisit and clean the util functions.

/**
* Get the deployment config.
*
* @returns Deployment config object.
*/
const getDeploymentConfig = (): DeploymentConfigInterface => {
return {
__experimental__platformIdP: window[ "AppUtils" ]?.getConfig()?.__experimental__platformIdP,
accountApp: window[ "AppUtils" ]?.getConfig()?.accountApp,
adminApp: window[ "AppUtils" ]?.getConfig()?.adminApp,
allowMultipleAppProtocols: window[ "AppUtils" ]?.getConfig()?.allowMultipleAppProtocols,
appBaseName: window[ "AppUtils" ]?.getConfig()?.appBaseWithTenant,
appBaseNameWithoutTenant: window[ "AppUtils" ]?.getConfig()?.appBase,
appHomePath: window[ "AppUtils" ]?.getConfig()?.routes?.home,
appLoginPath: window[ "AppUtils" ]?.getConfig()?.routes?.login,
appLogoutPath: window[ "AppUtils" ]?.getConfig()?.routes?.logout,
centralDeploymentEnabled: window[ "AppUtils" ]?.getConfig()?.centralDeploymentEnabled,
clientHost: window[ "AppUtils" ]?.getConfig()?.clientOriginWithTenant,
clientID: window[ "AppUtils" ]?.getConfig()?.clientID,
clientOrigin: window[ "AppUtils" ]?.getConfig()?.clientOrigin,
clientOriginWithTenant: window[ "AppUtils" ]?.getConfig()?.clientOriginWithTenant,
customServerHost: window[ "AppUtils" ]?.getConfig()?.customServerHost,
developerApp: window[ "AppUtils" ]?.getConfig()?.developerApp,
docSiteURL: window[ "AppUtils" ]?.getConfig()?.docSiteUrl,
extensions: window[ "AppUtils" ]?.getConfig()?.extensions,
idpConfigs: window[ "AppUtils" ]?.getConfig()?.idpConfigs,
loginCallbackUrl: window[ "AppUtils" ]?.getConfig()?.loginCallbackURL,
organizationPrefix: window["AppUtils"]?.getConfig()?.organizationPrefix,
serverHost: window[ "AppUtils" ]?.getConfig()?.serverOriginWithTenant,
serverOrigin: window[ "AppUtils" ]?.getConfig()?.serverOrigin,
superTenant: window[ "AppUtils" ]?.getConfig()?.superTenant,
tenant: window[ "AppUtils" ]?.getConfig()?.tenant,
tenantPath: window[ "AppUtils" ]?.getConfig()?.tenantPath,
tenantPrefix: window[ "AppUtils" ]?.getConfig()?.tenantPrefix
};
};

/**
* This method adds organization path to the server host if an organization is selected.
*
* @returns Server host.
*/
const resolveServerHost = (skipAuthzRuntimePath?: boolean): string => {
const serverOriginWithTenant: string = window["AppUtils"]?.getConfig()?.serverOriginWithTenant;

if (skipAuthzRuntimePath && serverOriginWithTenant?.slice(-2) === "/o") {
return serverOriginWithTenant.substring(0, serverOriginWithTenant.lastIndexOf("/o"));
}

return window["AppUtils"]?.getConfig()?.serverOriginWithTenant;
};

/**
* This method adds organization path (t/org_uuid) to the server host if a sub-org is selected.
*
* @returns Server host.
*/
const resolveServerHostforFG = (): string => {
if ((OrganizationUtils.isSuperOrganization(store.getState().organization.organization)
|| store.getState().organization.isFirstLevelOrganization)) {
return window[ "AppUtils" ]?.getConfig()?.serverOriginWithTenant;
} else {
return `${
window[ "AppUtils" ]?.getConfig()?.serverOrigin }/t/${ store.getState().organization.organization.id
}`;
}
};

/**
* Get the the list of service resource endpoints.
*
* @returns Service resource endpoints as an object.
*/
export const getServiceResourceEndpoints = (): ServiceResourceEndpointsInterface => {
const serviceResourceEndpoints: ServiceResourceEndpointsInterface = {
...getAPIResourceEndpoints(resolveServerHost()),
...getAdministratorsResourceEndpoints(resolveServerHost()),
...getApplicationsResourceEndpoints(resolveServerHost()),
...getApprovalsResourceEndpoints(getDeploymentConfig()?.serverHost),
...getBrandingResourceEndpoints(resolveServerHost()),
...getClaimResourceEndpoints(getDeploymentConfig()?.serverHost, resolveServerHost()),
...getCertificatesResourceEndpoints(getDeploymentConfig()?.serverHost),
...getIDVPResourceEndpoints(resolveServerHost()),
...getEmailTemplatesResourceEndpoints(resolveServerHost()),
...getConnectionResourceEndpoints(resolveServerHost()),
...getRolesResourceEndpoints(resolveServerHost(), getDeploymentConfig().serverHost),
...getServerConfigurationsResourceEndpoints(resolveServerHost()),
...getUsersResourceEndpoints(resolveServerHost()),
...getUserstoreResourceEndpoints(resolveServerHost()),
...getScopesResourceEndpoints(getDeploymentConfig()?.serverHost),
...getGroupsResourceEndpoints(resolveServerHost()),
...getValidationServiceEndpoints(resolveServerHost()),
...getRemoteFetchConfigResourceEndpoints(getDeploymentConfig()?.serverHost),
...getSecretsManagementEndpoints(getDeploymentConfig()?.serverHost),
...getExtendedFeatureResourceEndpoints(resolveServerHost(), getDeploymentConfig()),
...getOrganizationsResourceEndpoints(resolveServerHost(), getDeploymentConfig().serverHost),
...getTenantResourceEndpoints(getDeploymentConfig().serverOrigin),
...getFeatureGateResourceEndpoints(resolveServerHostforFG()),
...getInsightsResourceEndpoints(getDeploymentConfig()?.serverHost),
...getExtensionTemplatesEndpoints(resolveServerHost()),
...getApplicationTemplatesResourcesEndpoints(resolveServerHost()),
...getActionsResourceEndpoints(resolveServerHost()),
...getRulesEndpoints(resolveServerHost()),
...getSmsTemplateResourceEndpoints(resolveServerHost()),
...getPolicyAdministrationResourceEndpoints(resolveServerHost()),
...getPushProviderResourceEndpoints(resolveServerHost()),
...getPushProviderTemplateEndpoints(resolveServerHost()),
...getRemoteLoggingEndpoints(resolveServerHost()),
...getRegistrationFlowBuilderResourceEndpoints(resolveServerHost()),
CORSOrigins: `${getDeploymentConfig()?.serverHost}/api/server/v1/cors/origins`,
// TODO: Remove this endpoint and use ID token to get the details
me: `${getDeploymentConfig()?.serverHost}/scim2/Me`,
saml2Meta: `${resolveServerHost(true)}/identity/metadata/saml2`,
wellKnown: `${resolveServerHost(true)}/oauth2/token/.well-known/openid-configuration`
};

return serviceResourceEndpoints;
};
1 change: 0 additions & 1 deletion features/admin.authentication.v1/hooks/use-sign-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ const useSignIn = (): UseSignInInterface => {

await dispatch(
getProfileInformation(
Config.getServiceResourceEndpoints().me,
window["AppUtils"].getConfig().clientOriginWithTenant,
true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

import { AsgardeoSPAClient, DecodedIDTokenPayload } from "@asgardeo/auth-react";
import { Config } from "@wso2is/admin.core.v1/configs/app";
import { store } from "@wso2is/admin.core.v1/store";
import { getProfileInfo, getProfileSchemas } from "@wso2is/admin.users.v1/api";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
Expand All @@ -42,11 +41,12 @@ import { Dispatch } from "redux";
* Gets profile information by making an API call
*/
export const getProfileInformation = (
meEndpoint: string = Config.getServiceResourceEndpoints().me,
clientOrigin: string = window["AppUtils"].getConfig().clientOriginWithTenant,
fetchProfileSchema: boolean = false
) => (dispatch: Dispatch): void => {

const meEndpoint: string = store.getState().config.endpoints.me;

dispatch(setProfileInfoRequestLoadingStatus(true));

const isSubOrg: boolean = window[ "AppUtils" ].getConfig().organizationName;
Expand Down
4 changes: 3 additions & 1 deletion features/admin.core.v1/configs/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class Config {
* @returns Service resource endpoints as an object.
*/
public static getServiceResourceEndpoints(): ServiceResourceEndpointsInterface {
return {
const serviceResourceEndpoints: ServiceResourceEndpointsInterface = {
...getAPIResourceEndpoints(this.resolveServerHost()),
...getAdministratorsResourceEndpoints(this.resolveServerHost()),
...getApplicationsResourceEndpoints(this.resolveServerHost()),
Expand Down Expand Up @@ -300,6 +300,8 @@ export class Config {
saml2Meta: `${ this.resolveServerHost(false, true) }/identity/metadata/saml2`,
wellKnown: `${ this.resolveServerHost(false, true) }/oauth2/token/.well-known/openid-configuration`
};

return serviceResourceEndpoints;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2024-2025, 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
Expand All @@ -17,19 +17,19 @@
*/

import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react";
import { Config } from "@wso2is/admin.core.v1/configs/app";
import useRequest, {
RequestConfigInterface,
RequestErrorInterface,
RequestResultInterface
} from "@wso2is/admin.core.v1/hooks/use-request";
import { store } from "@wso2is/admin.core.v1/store";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import { HttpMethods } from "@wso2is/core/models";
import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
import { ImpersonationConfigConstants } from "../constants/impersonation-configuration";
import {
ImpersonationConfigAPIResponseInterface,
ImpersonationConfigPatchInterface
ImpersonationConfigPatchInterface
} from "../models/impersonation-configuration";

const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance()
Expand All @@ -49,7 +49,7 @@ export const useImpersonationConfig = <
"Content-Type": "application/json"
},
method: HttpMethods.GET,
url: Config.getServiceResourceEndpoints().impersonationConfigurations
url: store.getState().config.endpoints.impersonationConfigurations
};

const { data, error, isValidating, mutate } = useRequest<Data, Error>(requestConfig);
Expand Down Expand Up @@ -78,7 +78,7 @@ export const updateImpersonationConfigurations = (data: ImpersonationConfigPatch
"Content-Type": "application/json"
},
method: HttpMethods.PATCH,
url: Config.getServiceResourceEndpoints().impersonationConfigurations
url: store.getState().config.endpoints.impersonationConfigurations
};

return httpClient(requestConfig)
Expand Down
Loading
Loading