-`;
diff --git a/web/packages/teleport/src/Account/ManageDevices/AddDevice/index.ts b/web/packages/teleport/src/Account/ManageDevices/AddDevice/index.ts
deleted file mode 100644
index 4b80fe7dae511..0000000000000
--- a/web/packages/teleport/src/Account/ManageDevices/AddDevice/index.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Teleport
- * Copyright (C) 2023 Gravitational, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import AddDevice from './AddDevice';
-
-export default AddDevice;
diff --git a/web/packages/teleport/src/Account/ManageDevices/AddDevice/useAddDevice.ts b/web/packages/teleport/src/Account/ManageDevices/AddDevice/useAddDevice.ts
deleted file mode 100644
index 4c75db32d1109..0000000000000
--- a/web/packages/teleport/src/Account/ManageDevices/AddDevice/useAddDevice.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Teleport
- * Copyright (C) 2023 Gravitational, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import { useState, useEffect } from 'react';
-import useAttempt from 'shared/hooks/useAttemptNext';
-
-import Ctx from 'teleport/teleportContext';
-import authService from 'teleport/services/auth';
-import { DeviceUsage } from 'teleport/services/mfa';
-import cfg from 'teleport/config';
-
-export default function useAddDevice(
- ctx: Ctx,
- { token, restrictDeviceUsage, fetchDevices, onClose }: Props
-) {
- const [qrCode, setQrCode] = useState('');
- const addDeviceAttempt = useAttempt('');
- const fetchQrCodeAttempt = useAttempt('');
-
- function addTotpDevice(secondFactorToken: string, deviceName: string) {
- addDeviceAttempt.setAttempt({ status: 'processing' });
- ctx.mfaService
- .addNewTotpDevice({
- tokenId: token,
- secondFactorToken,
- deviceName,
- })
- .then(() => {
- onClose();
- fetchDevices();
- })
- .catch(addDeviceAttempt.handleError);
- }
-
- function addWebauthnDevice(deviceName: string, deviceUsage: DeviceUsage) {
- addDeviceAttempt.setAttempt({ status: 'processing' });
- ctx.mfaService
- .addNewWebauthnDevice({
- tokenId: token,
- deviceName,
- deviceUsage,
- })
- .then(() => {
- onClose();
- fetchDevices();
- })
- .catch(addDeviceAttempt.handleError);
- }
-
- function clearAttempt() {
- addDeviceAttempt.setAttempt({ status: '' });
- }
-
- useEffect(() => {
- fetchQrCodeAttempt.run(() =>
- authService
- .createMfaRegistrationChallenge(token, 'totp')
- .then(res => setQrCode(res.qrCode))
- );
- }, []);
-
- return {
- addDeviceAttempt: addDeviceAttempt.attempt,
- fetchQrCodeAttempt: fetchQrCodeAttempt.attempt,
- addTotpDevice,
- addWebauthnDevice,
- onClose,
- clearAttempt,
- qrCode,
- auth2faType: cfg.getAuth2faType(),
- isPasswordlessEnabled: cfg.isPasswordlessEnabled(),
- restrictDeviceUsage,
- };
-}
-
-export type State = ReturnType;
-
-export type Props = {
- token: string;
- /**
- * Controls whether the user can customize whether the device should allow
- * passwordless authentication. `undefined` means that the user gets to
- * choose; other values mean that the component's call site decides what kind
- * of device we're adding.
- *
- * TODO(bl-nero): Disallow `undefined` when cleaning up the old flow.
- */
- restrictDeviceUsage?: DeviceUsage;
- fetchDevices: () => void;
- onClose: () => void;
-};
diff --git a/web/packages/teleport/src/Account/ManageDevices/useManageDevices.ts b/web/packages/teleport/src/Account/ManageDevices/useManageDevices.ts
index 9335729de8b1d..15029f688729c 100644
--- a/web/packages/teleport/src/Account/ManageDevices/useManageDevices.ts
+++ b/web/packages/teleport/src/Account/ManageDevices/useManageDevices.ts
@@ -23,10 +23,6 @@ import Ctx from 'teleport/teleportContext';
import cfg from 'teleport/config';
import auth from 'teleport/services/auth';
import { DeviceUsage, MfaDevice } from 'teleport/services/mfa';
-import { storageService } from 'teleport/services/storageService';
-
-const useNewAddAuthDeviceDialog =
- storageService.isNewAddAuthDeviceDialogEnabled();
export default function useManageDevices(ctx: Ctx) {
const [devices, setDevices] = useState([]);
@@ -34,10 +30,9 @@ export default function useManageDevices(ctx: Ctx) {
const [deviceToRemove, setDeviceToRemove] = useState();
const [token, setToken] = useState('');
const fetchDevicesAttempt = useAttempt('');
- const [restrictNewDeviceUsage, setRestrictNewDeviceUsage] = useState<
- DeviceUsage | undefined
- >(undefined);
- const [passkeyWizardVisible, setPasskeyWizardVisible] = useState(false);
+ const [newDeviceUsage, setNewDeviceUsage] =
+ useState('passwordless');
+ const [addDeviceWizardVisible, setAddDeviceWizardVisible] = useState(false);
// This is a restricted privilege token that can only be used to add a device, in case
// the user has no devices yet and thus can't authenticate using the ReAuthenticate dialog
@@ -45,7 +40,6 @@ export default function useManageDevices(ctx: Ctx) {
const isReAuthenticateVisible = !token && isDialogVisible;
const isRemoveDeviceVisible = token && deviceToRemove && isDialogVisible;
- const isAddDeviceVisible = token && !deviceToRemove && isDialogVisible;
const isReauthenticationRequired = !token;
function fetchDevices() {
@@ -61,31 +55,23 @@ export default function useManageDevices(ctx: Ctx) {
});
}
- function onAddDevice(restrictUsage?: DeviceUsage) {
- const showDialog = useNewAddAuthDeviceDialog
- ? setPasskeyWizardVisible
- : setIsDialogVisible;
- setRestrictNewDeviceUsage(restrictUsage);
+ function onAddDevice(usage: DeviceUsage) {
+ setNewDeviceUsage(usage);
if (devices.length === 0) {
createRestrictedTokenAttempt.run(() =>
auth.createRestrictedPrivilegeToken().then(token => {
setToken(token);
- showDialog(true);
+ setAddDeviceWizardVisible(true);
})
);
} else {
- showDialog(true);
+ setAddDeviceWizardVisible(true);
}
}
- function onPasskeyAdded() {
+ function onDeviceAdded() {
fetchDevices();
- setPasskeyWizardVisible(false);
- setToken(null);
- }
-
- function hideAddDevice() {
- setIsDialogVisible(false);
+ setAddDeviceWizardVisible(false);
setToken(null);
}
@@ -104,8 +90,8 @@ export default function useManageDevices(ctx: Ctx) {
setIsDialogVisible(false);
}
- function closePasskeyWizard() {
- setPasskeyWizardVisible(false);
+ function closeAddDeviceWizard() {
+ setAddDeviceWizardVisible(false);
}
useEffect(() => fetchDevices(), []);
@@ -116,23 +102,20 @@ export default function useManageDevices(ctx: Ctx) {
setToken,
onAddDevice,
onRemoveDevice,
- onPasskeyAdded,
+ onDeviceAdded,
deviceToRemove,
- fetchDevices,
removeDevice,
fetchDevicesAttempt: fetchDevicesAttempt.attempt,
createRestrictedTokenAttempt: createRestrictedTokenAttempt.attempt,
isReAuthenticateVisible,
- isAddDeviceVisible,
isRemoveDeviceVisible,
isReauthenticationRequired,
- passkeyWizardVisible,
+ addDeviceWizardVisible,
hideReAuthenticate,
- hideAddDevice,
hideRemoveDevice,
- closePasskeyWizard,
+ closeAddDeviceWizard,
mfaDisabled: cfg.getAuth2faType() === 'off',
- restrictNewDeviceUsage,
+ newDeviceUsage,
};
}
diff --git a/web/packages/teleport/src/config.ts b/web/packages/teleport/src/config.ts
index fb5228f60d8b2..9481a71b2ca97 100644
--- a/web/packages/teleport/src/config.ts
+++ b/web/packages/teleport/src/config.ts
@@ -386,6 +386,10 @@ const cfg = {
return cfg.auth.allowPasswordless;
},
+ isMfaEnabled() {
+ return cfg.auth.second_factor !== 'off';
+ },
+
isAdminActionMfaEnforced() {
return cfg.auth.second_factor === 'webauthn';
},
diff --git a/web/packages/teleport/src/services/storageService/storageService.ts b/web/packages/teleport/src/services/storageService/storageService.ts
index dc920b20ceb70..eed88e41f2030 100644
--- a/web/packages/teleport/src/services/storageService/storageService.ts
+++ b/web/packages/teleport/src/services/storageService/storageService.ts
@@ -43,7 +43,6 @@ const KEEP_LOCALSTORAGE_KEYS_ON_LOGOUT = [
KeysEnum.SHOW_ASSIST_POPUP,
KeysEnum.USER_PREFERENCES,
KeysEnum.RECOMMEND_FEATURE,
- KeysEnum.NEW_ADD_AUTH_DEVICE_DIALOG,
];
export const storageService = {
@@ -254,8 +253,4 @@ export const storageService = {
JSON.stringify(true)
);
},
-
- isNewAddAuthDeviceDialogEnabled(): boolean {
- return this.getParsedJSONValue(KeysEnum.NEW_ADD_AUTH_DEVICE_DIALOG, false);
- },
};
diff --git a/web/packages/teleport/src/services/storageService/types.ts b/web/packages/teleport/src/services/storageService/types.ts
index 8260c51e0ace9..1faf82b6e66d9 100644
--- a/web/packages/teleport/src/services/storageService/types.ts
+++ b/web/packages/teleport/src/services/storageService/types.ts
@@ -35,10 +35,6 @@ export const KeysEnum = {
ACCESS_GRAPH_SQL_ENABLED: 'grv_teleport_access_graph_sql_enabled',
EXTERNAL_AUDIT_STORAGE_CTA_DISABLED:
'grv_teleport_external_audit_storage_disabled',
-
- // TODO(bl-nero): Remove this option once
- // https://github.com/gravitational/teleport/issues/37616 is resolved.
- NEW_ADD_AUTH_DEVICE_DIALOG: 'grv_new_add_auth_device_dialog',
};
// SurveyRequest is the request for sending data to the back end