🔀 Merge pull request #900 from Cereal916/disableConfigurationForNonAdmin

Add config option to disable all UI config features for non admin users.
This commit is contained in:
Alicia Sykes 2022-09-18 20:51:11 +01:00 committed by GitHub
commit 723da99d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 358 additions and 350 deletions

View File

@ -90,7 +90,7 @@ Any user who is not an admin (with `type: admin`) will not be able to write chan
You can also prevent any user from writing changes to disk, using `preventWriteToDisk`. Or prevent any changes from being saved locally in browser storage, using `preventLocalSave`. Both properties can be found under [`appConfig`](./docs/configuring.md#appconfig-optional). You can also prevent any user from writing changes to disk, using `preventWriteToDisk`. Or prevent any changes from being saved locally in browser storage, using `preventLocalSave`. Both properties can be found under [`appConfig`](./docs/configuring.md#appconfig-optional).
To disable all UI config features, including View Config, set `disableConfiguration`. To disable all UI config features, including View Config, set `disableConfiguration`. Alternatively you can disable UI config features for all non admin users by setting `disableConfigurationForNonAdmin` to true.
### Security ### Security

View File

@ -127,6 +127,7 @@ The following file provides a reference of all supported configuration options.
**`preventWriteToDisk`** | `boolean` | _Optional_ | If set to `true`, users will be prevented from saving config changes to disk through the UI **`preventWriteToDisk`** | `boolean` | _Optional_ | If set to `true`, users will be prevented from saving config changes to disk through the UI
**`preventLocalSave`** | `boolean` | _Optional_ | If set to `true`, users will be prevented from applying config changes to local storage **`preventLocalSave`** | `boolean` | _Optional_ | If set to `true`, users will be prevented from applying config changes to local storage
**`disableConfiguration`** | `boolean` | _Optional_ | If set to true, no users will be able to view or edit the config through the UI **`disableConfiguration`** | `boolean` | _Optional_ | If set to true, no users will be able to view or edit the config through the UI
**`disableConfigurationForNonAdmin`** | `boolean` | _Optional_ | If set to true, only admin users will be able to view or edit the config through the UI. disableConfiguration must not be set to true.
**`widgetsAlwaysUseProxy`** | `boolean` | _Optional_ | If set to `true`, requests made by widgets will always be proxied, same as setting `useProxy: true` on each widget. Note that this may break some widgets. **`widgetsAlwaysUseProxy`** | `boolean` | _Optional_ | If set to `true`, requests made by widgets will always be proxied, same as setting `useProxy: true` on each widget. Note that this may break some widgets.
**`showSplashScreen`** | `boolean` | _Optional_ | If set to `true`, a loading screen will be shown. Defaults to `false`. **`showSplashScreen`** | `boolean` | _Optional_ | If set to `true`, a loading screen will be shown. Defaults to `false`.
**`enableErrorReporting`** | `boolean` | _Optional_ | Enable reporting of unexpected errors and crashes. This is off by default, and **no data will ever be captured unless you explicitly enable it**. Turning on error reporting helps previously unknown bugs get discovered and fixed. Dashy uses [Sentry](https://github.com/getsentry/sentry) for error reporting. Defaults to `false`. **`enableErrorReporting`** | `boolean` | _Optional_ | Enable reporting of unexpected errors and crashes. This is off by default, and **no data will ever be captured unless you explicitly enable it**. Turning on error reporting helps previously unknown bugs get discovered and fixed. Dashy uses [Sentry](https://github.com/getsentry/sentry) for error reporting. Defaults to `false`.
@ -335,7 +336,7 @@ If you have authentication set up, then any user who is not an admin (with `type
You can also prevent changes from any user being written to disk, using `preventWriteToDisk`. Or prevent any changes from being saved locally in browser storage, using `preventLocalSave`. You can also prevent changes from any user being written to disk, using `preventWriteToDisk`. Or prevent any changes from being saved locally in browser storage, using `preventLocalSave`.
To disable all UI config features, set `disableConfiguration`. To disable all UI config features, set `disableConfiguration`. Alternatively you can disable UI config features for all non Admin users by setting `disableConfigurationForNonAdmin` to true.
### Example ### Example

View File

@ -107,7 +107,8 @@ const store = new Vuex.Store({
perms.allowWriteToDisk = false; perms.allowWriteToDisk = false;
} }
// Disable everything // Disable everything
if (appConfig.disableConfiguration) { if (appConfig.disableConfiguration
|| (appConfig.disableConfigurationForNonAdmin && !isUserAdmin())) {
perms.allowWriteToDisk = false; perms.allowWriteToDisk = false;
perms.allowSaveLocally = false; perms.allowSaveLocally = false;
perms.allowViewConfig = false; perms.allowViewConfig = false;

View File

@ -509,6 +509,12 @@
"default": false, "default": false,
"description": "If set to true, no users will be able to view or edit the config through the UI" "description": "If set to true, no users will be able to view or edit the config through the UI"
}, },
"disableConfigurationForNonAdmin": {
"title": "Disable all UI Config for non admin users.",
"type": "boolean",
"default": false,
"description": "If set to true, only admin users will be able to view or edit the config through the UI. disableConfiguration must not be set to true."
},
"allowConfigEdit": { "allowConfigEdit": {
"title": "Allow Config Editing", "title": "Allow Config Editing",
"type": "boolean", "type": "boolean",