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

Remove legacy trusted app UI #6693

Open
wants to merge 4 commits into
base: master
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
9 changes: 9 additions & 0 deletions .changeset/tall-beers-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@wso2is/admin.identity-providers.v1": patch
"@wso2is/admin.connections.v1": patch
"@wso2is/admin.extensions.v1": patch
"@wso2is/admin.core.v1": patch
"@wso2is/i18n": patch
---

Remove deprecated trusted apps UI
1 change: 0 additions & 1 deletion features/admin.connections.v1/configs/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const getConnectionResourceEndpoints = (serverHost: string): ConnectionRe
authenticators: `${ serverHost }/api/server/v1/authenticators`,
extensions: `${ serverHost }/api/server/v1/extensions`,
fidoConfigs: `${ serverHost }/api/identity/config-mgt/v1.0/resource/fido-config`,
fidoTrustedApps: `${ serverHost }/fido/trusted-apps-mgt`,
identityProviders: `${ serverHost }/api/server/v1/identity-providers`,
localAuthenticators: `${ serverHost }/api/server/v1/configs/authenticators`,
multiFactorAuthenticators: `${ serverHost }/api/server/v1/identity-governance/${
Expand Down
1 change: 0 additions & 1 deletion features/admin.connections.v1/models/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface ConnectionResourceEndpointsInterface {
authenticatorTags: string;
extensions: string;
fidoConfigs: string;
fidoTrustedApps: string;
identityProviders: string;
localAuthenticators: string;
multiFactorAuthenticators: string;
Expand Down
1 change: 0 additions & 1 deletion features/admin.core.v1/store/reducers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export const commonConfigReducerInitialState: CommonConfigReducerStateInterface<
extensions: "",
externalClaims: "",
fidoConfigs: "",
fidoTrustedApps: "",
getSecret: "",
getSecretList: "",
getSecretType: "",
Expand Down
1 change: 0 additions & 1 deletion features/admin.extensions.v1/configs/identity-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import SIWEIdPTemplate from "../identity-provider-templates/templates/swe/swe.js

export const identityProviderConfig: IdentityProviderConfig = {
editIdentityProvider: {
enableFIDOTrustedAppsConfiguration: false,
getOverriddenAuthenticatorForm: (
type: string,
templateId: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export interface ExtendedSamlConfigInterface {

export interface IdentityProviderConfig {
editIdentityProvider: {
enableFIDOTrustedAppsConfiguration: boolean;
showAdvancedSettings: boolean;
showIssuerSettings: boolean;
showJitProvisioning: boolean;
Expand Down
110 changes: 0 additions & 110 deletions features/admin.identity-providers.v1/api/fido-trusted-apps.ts
Original file line number Diff line number Diff line change
@@ -1,110 +0,0 @@
/**
* Copyright (c) 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 { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react";
import { ConnectionUIConstants } from "@wso2is/admin.connections.v1/constants/connection-ui-constants";
import { store } from "@wso2is/admin.core.v1";
import useRequest, {
RequestConfigInterface,
RequestErrorInterface,
RequestResultInterface
} from "@wso2is/admin.core.v1/hooks/use-request";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import { HttpMethods } from "@wso2is/core/models";
import { AxiosError, AxiosResponse } from "axios";
import { FIDOTrustedAppsResponseInterface } from "../models";

/**
* Get an axios instance.
*/
const httpClient: HttpClientInstance =
AsgardeoSPAClient.getInstance().httpRequest.bind(AsgardeoSPAClient.getInstance());

/**
* Hook to get the FIDO trusted apps.
*
* @param shouldFetch - Should fetch the data.
*
* @returns FIDO trusted apps list.
*/
export const useFIDOTrustedApps = <Data = FIDOTrustedAppsResponseInterface, Error = RequestErrorInterface>(
shouldFetch: boolean = true
): RequestResultInterface<Data, Error> => {

const requestConfig: RequestConfigInterface = {
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
method: HttpMethods.GET,
url: store?.getState()?.config?.endpoints?.fidoTrustedApps
};

const { data, error, isValidating, mutate } = useRequest<Data, Error>(shouldFetch ? requestConfig : null);

return {
data,
error: error,
isLoading: !error && !data,
isValidating,
mutate
};
};

/**
* Update the FIDO trusted apps.
*
* @param fidoTrustedApps - List of FIDO Trusted Apps.
*
* @returns Updated FIDO trusted apps list.
*/
export const updateFidoTrustedApps = (
fidoTrustedApps: FIDOTrustedAppsResponseInterface
): Promise<void> => {

const requestConfig: RequestConfigInterface = {
data: fidoTrustedApps,
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
method: HttpMethods.PUT,
url: store?.getState()?.config?.endpoints?.fidoTrustedApps
};

return httpClient(requestConfig)
.then((response: AxiosResponse) => {
if (response?.status !== 200) {
throw new IdentityAppsApiException(
ConnectionUIConstants.ERROR_MESSAGES.FIDO_TRUSTED_APPS_UPDATE_INVALID_STATUS_CODE_ERROR,
null,
response?.status,
response?.request,
response,
response?.config);
}
}).catch((error: AxiosError) => {
throw new IdentityAppsApiException(
ConnectionUIConstants.ERROR_MESSAGES.FIDO_TRUSTED_APPS_UPDATE_ERROR,
error?.stack,
error?.response?.data?.code,
error?.request,
error?.response,
error?.config);
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

import { ConnectionUIConstants } from "@wso2is/admin.connections.v1/constants/connection-ui-constants";
import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants";
import { identityProviderConfig } from "@wso2is/admin.extensions.v1";

Check warning on line 21 in features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-form.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

'identityProviderConfig' is defined but never used. Allowed unused vars must match /^_/u
import { updateFidoConfigs, useFIDOConnectorConfigs } from "@wso2is/admin.identity-providers.v1/api/fido-configs";
import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import { AlertLevels } from "@wso2is/core/models";
Expand All @@ -32,8 +33,7 @@
import { Trans, useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { Dispatch } from "redux";
import { FIDOTrustedApps } from "./fido-trusted-apps";
import { updateFidoConfigs, useFIDOConnectorConfigs } from "../../../../api/fido-configs";
import { IdentityProviderManagementConstants } from "../../../constants";

Check warning on line 36 in features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-form.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

'IdentityProviderManagementConstants' is defined but never used. Allowed unused vars must match /^_/u
import {
CommonAuthenticatorFormFieldMetaInterface,
CommonAuthenticatorFormInitialValuesInterface,
Expand All @@ -44,7 +44,7 @@
FIDOAuthenticatorFormPropsInterface,
FIDOConfigsInterface,
FIDOConnectorConfigsAttributeInterface
} from "../../../../models";
} from "../../../models";

const FORM_ID: string = "fido-authenticator-form";

Expand Down Expand Up @@ -81,7 +81,6 @@
] = useState<boolean>(undefined);
const [ isReadOnly ] = useState<boolean>(isSubOrganization() || readOnly);
const [ isFIDOConfigsSubmitting, setIsFIDOConfigsSubmitting ] = useState<boolean>(false);
const [ isFIDOTrustedAppsSubmitting, setIsFIDOTrustedAppsSubmitting ] = useState<boolean>(false);
const [ FIDOTrustedOrigins, setFIDOTrustedOrigins ] = useState<string>("");

const {
Expand Down Expand Up @@ -207,46 +206,44 @@

updateFidoConfigs(payload)
.then(() => {
dispatch(addAlert({
addAlert({
description: t("authenticationProvider:" +
"notifications.updateFIDOConnectorConfigs." +
"success.description"),
level: AlertLevels.SUCCESS,
message: t("authenticationProvider:notifications." +
"updateFIDOConnectorConfigs.success.message")
}));
});

mutateFIDOConnectorConfigs();
})
.catch((error: IdentityAppsApiException) => {
if (error?.response?.data?.description) {
dispatch(addAlert({
addAlert({
description: t("authenticationProvider:" +
"notifications.updateFIDOConnectorConfigs." +
"error.description", { description: error.response.data.description }),
level: AlertLevels.ERROR,
message: t("authenticationProvider:notifications." +
"updateFIDOConnectorConfigs.error.message")
}));
});

return;
}

dispatch(addAlert({
addAlert({
description: t("authenticationProvider:" +
"notifications.updateFIDOConnectorConfigs." +
"genericError.description"),
level: AlertLevels.ERROR,
message: t("authenticationProvider:" +
"notifications.updateFIDOConnectorConfigs." +
"genericError.message")
}));
});
})
.finally(() => setIsFIDOConfigsSubmitting(false));
};

let updateTrustedApps: (callback: () => void) => void;

/**
* Prepare form values for submitting.
*
Expand All @@ -260,11 +257,6 @@
updateFIDOConnectorConfigs();
}

if (identityProviderConfig?.editIdentityProvider?.enableFIDOTrustedAppsConfiguration) {
setIsFIDOTrustedAppsSubmitting(true);
updateTrustedApps(() => setIsFIDOTrustedAppsSubmitting(false));
}

const properties: CommonPluggableComponentPropertyInterface[] = [];

for (const [ name, value ] of Object.entries(values)) {
Expand Down Expand Up @@ -405,31 +397,18 @@
showPredictions={ false }
isAllowEnabled={ false }
skipValidation
readOnly={ isReadOnly }
/>)
}

{
identityProviderConfig?.editIdentityProvider?.enableFIDOTrustedAppsConfiguration && !isSubOrganization()
? (
<FIDOTrustedApps
readOnly={ isReadOnly }
triggerSubmission={ (submitFunction: (callback: () => void) => void) => {
updateTrustedApps = submitFunction;
} }
/>
)
: null
}
<Field.Button
form={ FORM_ID }
size="small"
buttonType="primary_btn"
ariaLabel="FIDO authenticator update button"
name="update-button"
data-testid={ `${ testId }-submit-button` }
disabled={ isSubmitting || isFIDOConfigsSubmitting || isFIDOTrustedAppsSubmitting }
loading={ isSubmitting || isFIDOConfigsSubmitting || isFIDOTrustedAppsSubmitting }
disabled={ isSubmitting || isFIDOConfigsSubmitting }
loading={ isSubmitting || isFIDOConfigsSubmitting }
label={ t("common:update") }
hidden={ isReadOnly }
/>
Expand Down

This file was deleted.

Loading
Loading