From d0df37bf9e202d8336d8507138971bf3d653d630 Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Fri, 3 Jan 2025 10:12:10 -0500 Subject: [PATCH 1/3] feat(api): rm 2fa & t2fa from myservers config type --- api/src/__test__/store/modules/config.test.ts | 18 +++--------------- api/src/store/modules/config.ts | 6 +----- api/src/types/my-servers-config.d.ts | 11 +---------- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/api/src/__test__/store/modules/config.test.ts b/api/src/__test__/store/modules/config.test.ts index 1243c8e0ab..dc9455ed83 100644 --- a/api/src/__test__/store/modules/config.test.ts +++ b/api/src/__test__/store/modules/config.test.ts @@ -14,16 +14,12 @@ test('Before init returns default values for all fields', async () => { "minigraph": "PRE_INIT", "upnpStatus": "", }, - "local": { - "2Fa": "", - "showT2Fa": "", - }, + "local": {}, "nodeEnv": "test", "notifier": { "apikey": "", }, "remote": { - "2Fa": "", "accesstoken": "", "allowedOrigins": "", "apikey": "", @@ -65,16 +61,12 @@ test('After init returns values from cfg file for all fields', async () => { minigraph: 'PRE_INIT', upnpStatus: '', }, - local: { - '2Fa': '', - showT2Fa: '', - }, + local: {}, nodeEnv: 'test', notifier: { apikey: 'unnotify_30994bfaccf839c65bae75f7fa12dd5ee16e69389f754c3b98ed7d5', }, remote: { - '2Fa': '', accesstoken: '', allowedOrigins: '', apikey: '_______________________BIG_API_KEY_HERE_________________________', @@ -122,16 +114,12 @@ test('updateUserConfig merges in changes to current state', async () => { minigraph: 'PRE_INIT', upnpStatus: '', }, - local: { - '2Fa': '', - showT2Fa: '', - }, + local: {}, nodeEnv: 'test', notifier: { apikey: 'unnotify_30994bfaccf839c65bae75f7fa12dd5ee16e69389f754c3b98ed7d5', }, remote: { - '2Fa': '', accesstoken: '', allowedOrigins: '', apikey: '_______________________BIG_API_KEY_HERE_________________________', diff --git a/api/src/store/modules/config.ts b/api/src/store/modules/config.ts index 6163297ad0..ea1fd7611f 100644 --- a/api/src/store/modules/config.ts +++ b/api/src/store/modules/config.ts @@ -35,7 +35,6 @@ export const initialState: SliceState = { status: FileLoadStatus.UNLOADED, nodeEnv: NODE_ENV, remote: { - '2Fa': '', wanaccess: '', wanport: '', upnpEnabled: '', @@ -51,10 +50,7 @@ export const initialState: SliceState = { allowedOrigins: '', dynamicRemoteAccessType: DynamicRemoteAccessType.DISABLED, }, - local: { - showT2Fa: '', - '2Fa': '', - }, + local: {}, api: { extraOrigins: '', version: '', diff --git a/api/src/types/my-servers-config.d.ts b/api/src/types/my-servers-config.d.ts index af37e9a466..488c8392fb 100644 --- a/api/src/types/my-servers-config.d.ts +++ b/api/src/types/my-servers-config.d.ts @@ -5,15 +5,11 @@ interface MyServersConfig extends Record { version: string; extraOrigins: string; }; - local: { - '2Fa'?: string; - showT2Fa?: string; - }; + local: {}; notifier: { apikey: string; }; remote: { - '2Fa'?: string; wanaccess: string; wanport: string; upnpEnabled?: string; @@ -38,12 +34,7 @@ export interface MyServersConfigWithMandatoryHiddenFields extends MyServersConfi api: { extraOrigins: string; }; - local: MyServersConfig['local'] & { - '2Fa': string; - showT2Fa: string; - }; remote: MyServersConfig['remote'] & { - '2Fa': string; upnpEnabled: string; dynamicRemoteAccessType: DynamicRemoteAccessType; }; From 1a672f8ef40b1cd4824ba9121bb870c0916fb81e Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Fri, 3 Jan 2025 10:18:08 -0500 Subject: [PATCH 2/3] feat(api): rm 2fa & T2fa from config normalizer --- .../utils/files/config-file-normalizer.test.ts | 15 +++++---------- .../core/utils/files/config-file-normalizer.ts | 6 +----- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/api/src/__test__/core/utils/files/config-file-normalizer.test.ts b/api/src/__test__/core/utils/files/config-file-normalizer.test.ts index cf3796a1bd..5a1d2c4506 100644 --- a/api/src/__test__/core/utils/files/config-file-normalizer.test.ts +++ b/api/src/__test__/core/utils/files/config-file-normalizer.test.ts @@ -80,9 +80,11 @@ test('it creates a MEMORY config with NO OPTIONAL values', () => { test('it creates a FLASH config with OPTIONAL values', () => { const basicConfig = cloneDeep(initialState); + // 2fa & t2fa should be ignored basicConfig.remote['2Fa'] = 'yes'; basicConfig.local['2Fa'] = 'yes'; basicConfig.local.showT2Fa = 'yes'; + basicConfig.api.extraOrigins = 'myextra.origins'; basicConfig.remote.upnpEnabled = 'yes'; basicConfig.connectionStatus.upnpStatus = 'Turned On'; @@ -93,15 +95,11 @@ test('it creates a FLASH config with OPTIONAL values', () => { "extraOrigins": "myextra.origins", "version": "", }, - "local": { - "2Fa": "yes", - "showT2Fa": "yes", - }, + "local": {}, "notifier": { "apikey": "", }, "remote": { - "2Fa": "yes", "accesstoken": "", "apikey": "", "avatar": "", @@ -125,6 +123,7 @@ test('it creates a FLASH config with OPTIONAL values', () => { test('it creates a MEMORY config with OPTIONAL values', () => { const basicConfig = cloneDeep(initialState); + // 2fa & t2fa should be ignored basicConfig.remote['2Fa'] = 'yes'; basicConfig.local['2Fa'] = 'yes'; basicConfig.local.showT2Fa = 'yes'; @@ -142,15 +141,11 @@ test('it creates a MEMORY config with OPTIONAL values', () => { "minigraph": "PRE_INIT", "upnpStatus": "Turned On", }, - "local": { - "2Fa": "yes", - "showT2Fa": "yes", - }, + "local": {}, "notifier": { "apikey": "", }, "remote": { - "2Fa": "yes", "accesstoken": "", "allowedOrigins": "/var/run/unraid-notifications.sock, /var/run/unraid-php.sock, /var/run/unraid-cli.sock, https://connect.myunraid.net, https://connect-staging.myunraid.net, https://dev-my.myunraid.net:4000", "apikey": "", diff --git a/api/src/core/utils/files/config-file-normalizer.ts b/api/src/core/utils/files/config-file-normalizer.ts index f6f82502cf..3ab27adce0 100644 --- a/api/src/core/utils/files/config-file-normalizer.ts +++ b/api/src/core/utils/files/config-file-normalizer.ts @@ -38,15 +38,11 @@ export const getWriteableConfig = ( version: api?.version ?? initialState.api.version, extraOrigins: api?.extraOrigins ?? initialState.api.extraOrigins, }, - local: { - ...(local?.['2Fa'] === 'yes' ? { '2Fa': local['2Fa'] } : {}), - ...(local?.showT2Fa === 'yes' ? { showT2Fa: local.showT2Fa } : {}), - }, + local: {}, notifier: { apikey: notifier.apikey ?? initialState.notifier.apikey, }, remote: { - ...(remote?.['2Fa'] === 'yes' ? { '2Fa': remote['2Fa'] } : {}), wanaccess: remote.wanaccess ?? initialState.remote.wanaccess, wanport: remote.wanport ?? initialState.remote.wanport, ...(remote.upnpEnabled ? { upnpEnabled: remote.upnpEnabled } : {}), From 0539473d08600955b004d8d0c851eab47a82225f Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Fri, 3 Jan 2025 10:19:41 -0500 Subject: [PATCH 3/3] doc(plugin): rm obsolete documentation on 2fa/t2fa feature --- plugin/docs/README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugin/docs/README.md b/plugin/docs/README.md index 869afc1896..4bd0a38e1a 100644 --- a/plugin/docs/README.md +++ b/plugin/docs/README.md @@ -2,12 +2,8 @@ # Hidden Flags Use the following flags for additional functionality -1. Setting showT2Fa to "yes" will give you early access to unreleased features, specifically T2FA and the ability to specify extra origins. -``` -[local] -showT2Fa="yes" -``` -2. The deleteOnUninstall setting is for internal developers who are switching between the staging and production plugins, or otherwise installing/uninstalling the plugin a lot. Setting this to "no" prevents the uninstall routine from deleting your local flash backup files and disabling Remote Access. The assumption is that you will be reinstalling the plugin and don't want to lose those settings. + +1. The deleteOnUninstall setting is for internal developers who are switching between the staging and production plugins, or otherwise installing/uninstalling the plugin a lot. Setting this to "no" prevents the uninstall routine from deleting your local flash backup files and disabling Remote Access. The assumption is that you will be reinstalling the plugin and don't want to lose those settings. ``` [plugin] deleteOnUninstall="no"