Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

⚑ Lazy load OIDC and KC code, only when needed

Alicia Sykes6699851496cb
diff --git a/src/utils/auth/KeycloakAuth.js b/src/utils/auth/KeycloakAuth.js
index fb5320bc..2dcfd86f 100644
--- a/src/utils/auth/KeycloakAuth.js
+++ b/src/utils/auth/KeycloakAuth.js
@@ -1,4 +1,3 @@
-import Keycloak from 'keycloak-js';
import ConfigAccumulator from '@/utils/config/ConfigAccumalator';
import { localStorageKeys } from '@/utils/config/defaults';
import ErrorHandler from '@/utils/logging/ErrorHandler';
@@ -15,7 +14,7 @@ const isKeycloakGuestAccessEnabled = () => {
};
class KeycloakAuth {
- constructor() {
+ constructor(Keycloak) {
const { auth } = getAppConfig();
const {
serverUrl, realm, clientId, idpHint, legacySupport,
@@ -97,8 +96,9 @@ export const isKeycloakEnabled = () => {
let keycloak;
-export const initKeycloakAuth = () => {
- keycloak = new KeycloakAuth();
+export const initKeycloakAuth = async () => {
+ const { default: Keycloak } = await import('keycloak-js');
+ keycloak = new KeycloakAuth(Keycloak);
return keycloak.login();
};
diff --git a/src/utils/auth/OidcAuth.js b/src/utils/auth/OidcAuth.js
index 656c95cb..77234bcb 100644
--- a/src/utils/auth/OidcAuth.js
+++ b/src/utils/auth/OidcAuth.js
@@ -1,4 +1,3 @@
-import { UserManager, WebStorageStateStore } from 'oidc-client-ts';
import ConfigAccumulator from '@/utils/config/ConfigAccumalator';
import { localStorageKeys } from '@/utils/config/defaults';
import ErrorHandler from '@/utils/logging/ErrorHandler';
@@ -16,7 +15,7 @@ const isOidcGuestAccessEnabled = () => {
};
class OidcAuth {
- constructor() {
+ constructor(UserManager, WebStorageStateStore) {
const { auth } = getAppConfig();
const {
clientId,
@@ -105,8 +104,9 @@ export const isOidcEnabled = () => {
let oidc;
-export const initOidcAuth = () => {
- oidc = new OidcAuth();
+export const initOidcAuth = async () => {
+ const { UserManager, WebStorageStateStore } = await import('oidc-client-ts');
+ oidc = new OidcAuth(UserManager, WebStorageStateStore);
return oidc.login();
};