Skip to content

Commit 89e791a

Browse files
authored
feat(api): rm 2fa & t2fa from myservers config type (#996)
* feat(api): rm 2fa & t2fa from myservers config type * feat(api): rm 2fa & T2fa from config normalizer * doc(plugin): rm obsolete documentation on 2fa/t2fa feature
1 parent e2148f3 commit 89e791a

File tree

6 files changed

+13
-51
lines changed

6 files changed

+13
-51
lines changed

api/src/__test__/core/utils/files/config-file-normalizer.test.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ test('it creates a MEMORY config with NO OPTIONAL values', () => {
8080

8181
test('it creates a FLASH config with OPTIONAL values', () => {
8282
const basicConfig = cloneDeep(initialState);
83+
// 2fa & t2fa should be ignored
8384
basicConfig.remote['2Fa'] = 'yes';
8485
basicConfig.local['2Fa'] = 'yes';
8586
basicConfig.local.showT2Fa = 'yes';
87+
8688
basicConfig.api.extraOrigins = 'myextra.origins';
8789
basicConfig.remote.upnpEnabled = 'yes';
8890
basicConfig.connectionStatus.upnpStatus = 'Turned On';
@@ -93,15 +95,11 @@ test('it creates a FLASH config with OPTIONAL values', () => {
9395
"extraOrigins": "myextra.origins",
9496
"version": "",
9597
},
96-
"local": {
97-
"2Fa": "yes",
98-
"showT2Fa": "yes",
99-
},
98+
"local": {},
10099
"notifier": {
101100
"apikey": "",
102101
},
103102
"remote": {
104-
"2Fa": "yes",
105103
"accesstoken": "",
106104
"apikey": "",
107105
"avatar": "",
@@ -125,6 +123,7 @@ test('it creates a FLASH config with OPTIONAL values', () => {
125123

126124
test('it creates a MEMORY config with OPTIONAL values', () => {
127125
const basicConfig = cloneDeep(initialState);
126+
// 2fa & t2fa should be ignored
128127
basicConfig.remote['2Fa'] = 'yes';
129128
basicConfig.local['2Fa'] = 'yes';
130129
basicConfig.local.showT2Fa = 'yes';
@@ -142,15 +141,11 @@ test('it creates a MEMORY config with OPTIONAL values', () => {
142141
"minigraph": "PRE_INIT",
143142
"upnpStatus": "Turned On",
144143
},
145-
"local": {
146-
"2Fa": "yes",
147-
"showT2Fa": "yes",
148-
},
144+
"local": {},
149145
"notifier": {
150146
"apikey": "",
151147
},
152148
"remote": {
153-
"2Fa": "yes",
154149
"accesstoken": "",
155150
"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",
156151
"apikey": "",

api/src/__test__/store/modules/config.test.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@ test('Before init returns default values for all fields', async () => {
1414
"minigraph": "PRE_INIT",
1515
"upnpStatus": "",
1616
},
17-
"local": {
18-
"2Fa": "",
19-
"showT2Fa": "",
20-
},
17+
"local": {},
2118
"nodeEnv": "test",
2219
"notifier": {
2320
"apikey": "",
2421
},
2522
"remote": {
26-
"2Fa": "",
2723
"accesstoken": "",
2824
"allowedOrigins": "",
2925
"apikey": "",
@@ -65,16 +61,12 @@ test('After init returns values from cfg file for all fields', async () => {
6561
minigraph: 'PRE_INIT',
6662
upnpStatus: '',
6763
},
68-
local: {
69-
'2Fa': '',
70-
showT2Fa: '',
71-
},
64+
local: {},
7265
nodeEnv: 'test',
7366
notifier: {
7467
apikey: 'unnotify_30994bfaccf839c65bae75f7fa12dd5ee16e69389f754c3b98ed7d5',
7568
},
7669
remote: {
77-
'2Fa': '',
7870
accesstoken: '',
7971
allowedOrigins: '',
8072
apikey: '_______________________BIG_API_KEY_HERE_________________________',
@@ -122,16 +114,12 @@ test('updateUserConfig merges in changes to current state', async () => {
122114
minigraph: 'PRE_INIT',
123115
upnpStatus: '',
124116
},
125-
local: {
126-
'2Fa': '',
127-
showT2Fa: '',
128-
},
117+
local: {},
129118
nodeEnv: 'test',
130119
notifier: {
131120
apikey: 'unnotify_30994bfaccf839c65bae75f7fa12dd5ee16e69389f754c3b98ed7d5',
132121
},
133122
remote: {
134-
'2Fa': '',
135123
accesstoken: '',
136124
allowedOrigins: '',
137125
apikey: '_______________________BIG_API_KEY_HERE_________________________',

api/src/core/utils/files/config-file-normalizer.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,11 @@ export const getWriteableConfig = <T extends ConfigType>(
3838
version: api?.version ?? initialState.api.version,
3939
extraOrigins: api?.extraOrigins ?? initialState.api.extraOrigins,
4040
},
41-
local: {
42-
...(local?.['2Fa'] === 'yes' ? { '2Fa': local['2Fa'] } : {}),
43-
...(local?.showT2Fa === 'yes' ? { showT2Fa: local.showT2Fa } : {}),
44-
},
41+
local: {},
4542
notifier: {
4643
apikey: notifier.apikey ?? initialState.notifier.apikey,
4744
},
4845
remote: {
49-
...(remote?.['2Fa'] === 'yes' ? { '2Fa': remote['2Fa'] } : {}),
5046
wanaccess: remote.wanaccess ?? initialState.remote.wanaccess,
5147
wanport: remote.wanport ?? initialState.remote.wanport,
5248
...(remote.upnpEnabled ? { upnpEnabled: remote.upnpEnabled } : {}),

api/src/store/modules/config.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export const initialState: SliceState = {
3737
status: FileLoadStatus.UNLOADED,
3838
nodeEnv: NODE_ENV,
3939
remote: {
40-
'2Fa': '',
4140
wanaccess: '',
4241
wanport: '',
4342
upnpEnabled: '',
@@ -53,10 +52,7 @@ export const initialState: SliceState = {
5352
allowedOrigins: '',
5453
dynamicRemoteAccessType: DynamicRemoteAccessType.DISABLED,
5554
},
56-
local: {
57-
showT2Fa: '',
58-
'2Fa': '',
59-
},
55+
local: {},
6056
api: {
6157
extraOrigins: '',
6258
version: '',

api/src/types/my-servers-config.d.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ interface MyServersConfig extends Record<string, unknown> {
55
version: string;
66
extraOrigins: string;
77
};
8-
local: {
9-
'2Fa'?: string;
10-
showT2Fa?: string;
11-
};
8+
local: {};
129
notifier: {
1310
apikey: string;
1411
};
1512
remote: {
16-
'2Fa'?: string;
1713
wanaccess: string;
1814
wanport: string;
1915
upnpEnabled?: string;
@@ -38,12 +34,7 @@ export interface MyServersConfigWithMandatoryHiddenFields extends MyServersConfi
3834
api: {
3935
extraOrigins: string;
4036
};
41-
local: MyServersConfig['local'] & {
42-
'2Fa': string;
43-
showT2Fa: string;
44-
};
4537
remote: MyServersConfig['remote'] & {
46-
'2Fa': string;
4738
upnpEnabled: string;
4839
dynamicRemoteAccessType: DynamicRemoteAccessType;
4940
};

plugin/docs/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
# Hidden Flags
33

44
Use the following flags for additional functionality
5-
1. Setting showT2Fa to "yes" will give you early access to unreleased features, specifically T2FA and the ability to specify extra origins.
6-
```
7-
[local]
8-
showT2Fa="yes"
9-
```
10-
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.
5+
6+
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.
117
```
128
[plugin]
139
deleteOnUninstall="no"

0 commit comments

Comments
 (0)