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
This commit is contained in:
Pujit Mehrotra
2025-01-08 14:15:15 -05:00
committed by GitHub
parent acba0b0365
commit f45719fa6b
6 changed files with 26 additions and 45 deletions

View File

@@ -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": "",

View File

@@ -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_________________________',

View File

@@ -38,15 +38,11 @@ export const getWriteableConfig = <T extends ConfigType>(
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 } : {}),

View File

@@ -37,7 +37,6 @@ export const initialState: SliceState = {
status: FileLoadStatus.UNLOADED,
nodeEnv: NODE_ENV,
remote: {
'2Fa': '',
wanaccess: '',
wanport: '',
upnpEnabled: '',
@@ -53,10 +52,7 @@ export const initialState: SliceState = {
allowedOrigins: '',
dynamicRemoteAccessType: DynamicRemoteAccessType.DISABLED,
},
local: {
showT2Fa: '',
'2Fa': '',
},
local: {},
api: {
extraOrigins: '',
version: '',

View File

@@ -5,15 +5,11 @@ interface MyServersConfig extends Record<string, unknown> {
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;
};

15
plugin/docs/README.md Normal file
View File

@@ -0,0 +1,15 @@
# Hidden Flags
Use the following flags for additional functionality
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"
```
# Plugin Hosted Urls
- Main: https://s3.amazonaws.com/dnld.lime-technology.com/unraid-api/dynamix.unraid.net.plg
- Staging: https://s3.amazonaws.com/dnld.lime-technology.com/unraid-api/dynamix.unraid.net.staging.plg