From 8665c6010db7178a7527e00c4fb7907d02c10589 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 13 Jun 2021 09:39:44 +0100 Subject: [PATCH 1/4] Adds new fields for user authentication --- docs/configuring.md | 11 +++++++++++ src/utils/ConfigSchema.json | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/docs/configuring.md b/docs/configuring.md index addbb4a6d6..acae2cae3e 100644 --- a/docs/configuring.md +++ b/docs/configuring.md @@ -55,6 +55,17 @@ All fields are optional, unless otherwise stated. **`externalStyleSheet`** | `string` or `string[]` | _Optional_ | Either a URL to an external stylesheet or an array or URLs, which can be applied as themes within the UI **`customCss`** | `string` | _Optional_ | Raw CSS that will be applied to the page. This can also be set from the UI. Please minify it first. **`showSplashScreen`** | `boolean` | _Optional_ | Should display a splash screen while the app is loading. Defaults to false, except on first load +**`auth`** | `array` | _Optional_ | An array of objects containing usernames and hashed passwords. If this is not provided, then authentication will be off by default, and you will not need any credentials to access the app. Note authentication is done on the client side, and so if your instance of Dashy is exposed to the internet, it is recommend to configure your web server to handle this. See [`auth`](#appconfigauth-optional) + +**[⬆️ Back to Top](#configuring)** + +#### `appConfig.auth` _(optional)_ + +**Field** | **Type** | **Required**| **Description** +--- | --- | --- | --- +**`user`** | `string` | Required | Username to log in with +**`hash`** | `string` | Required | A SHA-256 hashed password +**`type`** | `string` | _Optional_ | The user type, either admin or normal **[⬆️ Back to Top](#configuring)** diff --git a/src/utils/ConfigSchema.json b/src/utils/ConfigSchema.json index 365083f747..748b649d97 100644 --- a/src/utils/ConfigSchema.json +++ b/src/utils/ConfigSchema.json @@ -94,6 +94,38 @@ "type": "boolean", "default": false, "description": "Display a loading screen when the app is launched" + }, + "auth": { + "type": "array", + "description": "Usernames and hashed credentials for frontend authentication", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "user", + "hash" + ], + "properties": { + "user": { + "type": "string", + "description": "The username for a user" + }, + "hash": { + "type": "string", + "description": "A SHA-256 hashed password for that user", + "minLength": 64, + "maxLength": 64 + }, + "type": { + "enum": [ + "admin", + "normal" + ], + "description": "User type, denoting privilege level, either admin or normal", + "default": "normal" + } + } + } } }, "additionalProperties": false From 25ee90b987febff8d3b8c4f78b937c34989a9a65 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 13 Jun 2021 09:40:40 +0100 Subject: [PATCH 2/4] Adds functionality and supporting components for frontend authentication --- src/assets/interface-icons/user-logout.svg | 1 + src/components/FormElements/Button.vue | 1 + src/components/Settings/SettingsContainer.vue | 38 +++++ src/router.js | 38 ++++- src/styles/color-palette.scss | 3 + src/utils/Auth.js | 52 +++++++ src/utils/defaults.js | 4 + src/views/Login.vue | 132 ++++++++++++++++++ 8 files changed, 263 insertions(+), 6 deletions(-) create mode 100644 src/assets/interface-icons/user-logout.svg create mode 100644 src/utils/Auth.js create mode 100644 src/views/Login.vue diff --git a/src/assets/interface-icons/user-logout.svg b/src/assets/interface-icons/user-logout.svg new file mode 100644 index 0000000000..5c9daff8f7 --- /dev/null +++ b/src/assets/interface-icons/user-logout.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/FormElements/Button.vue b/src/components/FormElements/Button.vue index 4ea452d1fc..5867463421 100644 --- a/src/components/FormElements/Button.vue +++ b/src/components/FormElements/Button.vue @@ -1,5 +1,6 @@