🛂 Legacy support op for Keycloak v17 (#564)

This commit is contained in:
Alicia Sykes 2022-05-16 21:45:13 +01:00
parent c04e80b44e
commit 19b71313d5
4 changed files with 13 additions and 2 deletions

View File

@ -146,6 +146,8 @@ appConfig:
clientId: 'dashy' clientId: 'dashy'
``` ```
Note that if you are using Keycloak V 17 or older, you will also need to set `legacySupport: true` (also under `appConfig.auth.keycloak`). This is because the API endpoint was updated in later versions.
### 4. Add groups and roles (Optional) ### 4. Add groups and roles (Optional)
Keycloak allows you to assign users roles and groups. You can use these values to configure who can access various sections in Dashy. Keycloak allows you to assign users roles and groups. You can use these values to configure who can access various sections in Dashy.
Keycloak server administration and configuration is a deep topic; please refer to the [server admin guide](https://www.keycloak.org/docs/latest/server_admin/index.html#assigning-permissions-and-access-using-roles-and-groups) to see details about creating and assigning roles and groups. Keycloak server administration and configuration is a deep topic; please refer to the [server admin guide](https://www.keycloak.org/docs/latest/server_admin/index.html#assigning-permissions-and-access-using-roles-and-groups) to see details about creating and assigning roles and groups.

View File

@ -163,6 +163,7 @@ For more info, see the **[Authentication Docs](/docs/authentication.md)**
**`serverUrl`** | `string` | Required | The URL (or URL/ IP + Port) where your keycloak server is running **`serverUrl`** | `string` | Required | The URL (or URL/ IP + Port) where your keycloak server is running
**`realm`** | `string` | Required | The name of the realm (must already be created) that you want to use **`realm`** | `string` | Required | The name of the realm (must already be created) that you want to use
**`clientId`** | `string` | Required | The Client ID of the client you created for use with Dashy **`clientId`** | `string` | Required | The Client ID of the client you created for use with Dashy
**`legacySupport`** | `boolean` | _Optional_ | If using Keycloak 17 or older, then set this to `true`
**[⬆️ Back to Top](#configuring)** **[⬆️ Back to Top](#configuring)**

View File

@ -475,6 +475,11 @@
"title": "Client ID", "title": "Client ID",
"type": "string", "type": "string",
"description": "The Client ID of the client you created for use with Dashy" "description": "The Client ID of the client you created for use with Dashy"
},
"legacySupport": {
"title": "Legacy Support",
"type": "boolean",
"description": "If using Keycloak 17 or older, then set this to true"
} }
} }
} }

View File

@ -12,9 +12,12 @@ const getAppConfig = () => {
class KeycloakAuth { class KeycloakAuth {
constructor() { constructor() {
const { auth } = getAppConfig(); const { auth } = getAppConfig();
const { serverUrl, realm, clientId } = auth.keycloak; const {
serverUrl, realm, clientId, legacySupport,
} = auth.keycloak;
const url = legacySupport ? `${serverUrl}/auth` : serverUrl;
const initOptions = { const initOptions = {
url: `${serverUrl}`, realm, clientId, onLoad: 'login-required', url, realm, clientId, onLoad: 'login-required',
}; };
this.keycloakClient = Keycloak(initOptions); this.keycloakClient = Keycloak(initOptions);