@open-pioneer/authentication-keycloak 4.8.0-dev.20260910101405 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -83
- package/KeycloakAuthPluginImpl.js.map +1 -1
- package/_virtual/source-info.js.map +1 -1
- package/getKeycloakConfig.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @open-pioneer/authentication-keycloak
|
|
2
2
|
|
|
3
|
-
## 4.8.0
|
|
3
|
+
## 4.8.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -62,53 +62,53 @@
|
|
|
62
62
|
|
|
63
63
|
- f67fd7e: Support configuration of keycloak's login options and logout options.
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
65
|
+
For example, to redirect to a different site after logout:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
// app.ts
|
|
69
|
+
const element = createCustomElement({
|
|
70
|
+
component: AppUI,
|
|
71
|
+
appMetadata,
|
|
72
|
+
config: {
|
|
73
|
+
properties: {
|
|
74
|
+
"@open-pioneer/authentication-keycloak": {
|
|
75
|
+
keycloakOptions: {
|
|
76
|
+
// ...
|
|
77
|
+
keycloakLogoutOptions: {
|
|
78
|
+
redirectUri: "https://example.com"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} satisfies KeycloakProperties
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The plugin also supports options for the `logout` method to supply dynamic logout options:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
// via auth service
|
|
91
|
+
const authService = ...;
|
|
92
|
+
authService.logout({
|
|
93
|
+
// These are passed directly the keycloak plugin (if it is being used).
|
|
94
|
+
pluginOptions: {
|
|
95
|
+
redirectUri: "https://example.com",
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// via direct reference to the plugin ("authentication-keycloak.KeycloakAuthPlugin")
|
|
100
|
+
const keycloakAuthPlugin = ...;
|
|
101
|
+
keycloakAuthPlugin.logout({
|
|
102
|
+
redirectUri: "https://example.com",
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
105
|
|
|
106
106
|
- f67fd7e: Make `RefreshOptions` optional with sensible default values. The default values have been changed to:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
- `autoRefresh`: true
|
|
108
|
+
- `interval` (for token lifetime checks): 10 seconds
|
|
109
|
+
- `timeLeft`: 60 seconds (minimum required lifetime during token validity checks)
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
These values are used when they are not explicitly configured using package properties.
|
|
112
112
|
|
|
113
113
|
### Patch Changes
|
|
114
114
|
|
|
@@ -132,13 +132,13 @@
|
|
|
132
132
|
### Major Changes
|
|
133
133
|
|
|
134
134
|
- 9477e54: Update dependencies
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
- React 19
|
|
136
|
+
- Vite 6
|
|
137
|
+
- FormatJS 3
|
|
138
|
+
- Open Pioneer Build Tools
|
|
139
|
+
- ...
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
|
|
142
142
|
|
|
143
143
|
## 2.4.0
|
|
144
144
|
|
|
@@ -146,39 +146,39 @@
|
|
|
146
146
|
|
|
147
147
|
- 1ce5f11: Replace change events for auth state with signals from Reactivity API
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
149
|
+
Example: watch for updates of the auth state
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const myAuthService = ...
|
|
153
|
+
watch(
|
|
154
|
+
() => [myAuthService.getAuthState()],
|
|
155
|
+
([state]) => {
|
|
156
|
+
console.log(state);
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
immediate: true
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The Auth Service forwards the auth state from the underlying AuthPlugin.
|
|
165
|
+
Therefore, the plugin implementation must use reactive signals when its auth state changes in order to signal changes to the service.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
class DummyPlugin implements AuthPlugin {
|
|
169
|
+
#state = reactive<AuthState>({
|
|
170
|
+
kind: "not-authenticated"
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
getAuthState(): AuthState {
|
|
174
|
+
return this.#state.value;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
$setAuthState(newState: AuthState) {
|
|
178
|
+
this.#state.value = newState;
|
|
179
|
+
}
|
|
179
180
|
}
|
|
180
|
-
|
|
181
|
-
```
|
|
181
|
+
```
|
|
182
182
|
|
|
183
183
|
### Patch Changes
|
|
184
184
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeycloakAuthPluginImpl.js","sources":["KeycloakAuthPluginImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { reactive } from \"@conterra/reactivity-core\";\nimport { AuthState, LoginBehavior } from \"@open-pioneer/authentication\";\nimport { createLogger, destroyResource, Resource } from \"@open-pioneer/core\";\nimport { NotificationService } from \"@open-pioneer/notifier\";\nimport {\n PackageIntl,\n Service,\n ServiceOptions,\n DECLARE_SERVICE_INTERFACE\n} from \"@open-pioneer/runtime\";\nimport Keycloak, { KeycloakLogoutOptions } from \"keycloak-js\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { KeycloakAuthPlugin } from \"./api\";\nimport { getKeycloakConfig, ResolvedKeycloakOptions } from \"./getKeycloakConfig\";\n\nconst LOG = createLogger(sourceId);\n\ninterface References {\n notifier: NotificationService;\n}\n\nexport class KeycloakAuthPluginImpl implements Service, KeycloakAuthPlugin {\n declare [DECLARE_SERVICE_INTERFACE]: \"authentication-keycloak.KeycloakAuthPlugin\";\n\n #notifier: NotificationService;\n #intl: PackageIntl;\n #keycloakOptions: ResolvedKeycloakOptions;\n #keycloak: Keycloak;\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n #timerId: any;\n #watcher: Resource | undefined;\n\n #state = reactive<AuthState>({\n kind: \"pending\"\n });\n\n constructor(options: ServiceOptions<References>) {\n this.#notifier = options.references.notifier;\n this.#intl = options.intl;\n\n try {\n this.#keycloakOptions = getKeycloakConfig(options.properties);\n } catch (e) {\n throw new Error(\"Invalid keycloak configuration\", { cause: e });\n }\n\n try {\n this.#keycloak = new Keycloak(this.#keycloakOptions.config);\n } catch (e) {\n throw new Error(\"Failed to construct keycloak instance\", { cause: e });\n }\n this.#init().catch((e) => {\n this.#updateState({\n kind: \"error\",\n error: e\n });\n this.#notifier.notify({\n level: \"error\",\n title: this.#intl.formatMessage({\n id: \"loginFailed.title\"\n }),\n message: this.#intl.formatMessage({\n id: \"loginFailed.message\"\n })\n });\n\n LOG.error(\"Failed to check if user is authenticated\", e);\n });\n }\n\n destroy() {\n clearInterval(this.#timerId);\n this.#watcher = destroyResource(this.#watcher);\n this.#timerId = undefined;\n }\n\n getAuthState(): AuthState {\n return this.#state.value;\n }\n\n getLoginBehavior(): LoginBehavior {\n const doLogin = () => {\n const options = this.#keycloakOptions.loginOptions;\n LOG.debug(\"Login with options\", options);\n this.#keycloak.login(options);\n };\n return {\n kind: \"effect\",\n login: doLogin\n };\n }\n\n logout(options?: Partial<KeycloakLogoutOptions>) {\n const logoutOptions = {\n ...this.#keycloakOptions.logoutOptions,\n ...options\n };\n LOG.debug(\"Logout with options\", logoutOptions);\n this.#keycloak.logout(logoutOptions);\n }\n\n async #init() {\n const { initOptions, refreshOptions } = this.#keycloakOptions;\n\n let isAuthenticated: boolean;\n try {\n LOG.debug(\"Init with options\", initOptions);\n isAuthenticated = await this.#keycloak.init(initOptions);\n } catch (e) {\n // Note: keycloak.init() can also throw an exception, in addition to a rejected promise.\n // It may also just throw a string..\n const error = typeof e === \"string\" ? new Error(e) : e;\n\n // oxlint-disable-next-line preserve-caught-error\n throw new Error(\"Failed to initialize keycloak session\", { cause: error });\n }\n\n if (isAuthenticated) {\n this.#updateState({\n kind: \"authenticated\",\n sessionInfo: {\n userId: this.#keycloak.subject ? this.#keycloak.subject : \"undefined\",\n userName: this.#keycloak.idTokenParsed?.preferred_username,\n attributes: {\n keycloak: this.#keycloak,\n familyName: this.#keycloak.idTokenParsed?.family_name,\n givenName: this.#keycloak.idTokenParsed?.given_name,\n userName: this.#keycloak.idTokenParsed?.preferred_username\n }\n }\n });\n\n LOG.debug(`User ${this.#keycloak.subject} is authenticated`);\n\n if (refreshOptions.autoRefresh) {\n LOG.debug(\"Starting auto-refresh\", refreshOptions);\n this.__refresh(refreshOptions.interval, refreshOptions.timeLeft);\n }\n } else {\n this.#updateState({\n kind: \"not-authenticated\"\n });\n LOG.debug(\"User is not authenticated\");\n }\n }\n\n // Mocked in test (must stay on the prototype so `vi.spyOn` can replace it;\n // a private `#` method would not be spyable).\n __refresh(interval: number, timeLeft: number) {\n clearInterval(this.#timerId);\n this.#timerId = setInterval(() => {\n LOG.debug(\"Checking token validity\");\n this.#keycloak\n .updateToken(timeLeft)\n .then((refreshed) => {\n if (refreshed) {\n LOG.debug(\"Token refreshed successfully\");\n } else {\n LOG.debug(\"Token is still valid\");\n }\n })\n .catch((e) => {\n LOG.error(\"Failed to refresh token\", e);\n this.#updateState({\n kind: \"not-authenticated\"\n });\n this.destroy();\n });\n }, interval);\n }\n\n #updateState(newState: AuthState) {\n this.#state.value = newState;\n }\n}\n"],"names":[],"mappings":";;;;;;AAkBA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAM1B,MAAM,sBAAA,CAA8D;AAAA,EAGvE,SAAA;AAAA,EACA,KAAA;AAAA,EACA,gBAAA;AAAA,EACA,SAAA;AAAA;AAAA,EAGA,QAAA;AAAA,EACA,QAAA;AAAA,EAEA,SAAS,QAAA,CAAoB;AAAA,IACzB,IAAA,EAAM;AAAA,GACT,CAAA;AAAA,EAED,YAAY,OAAA,EAAqC;AAC7C,IAAA,IAAA,CAAK,SAAA,GAAY,QAAQ,UAAA,CAAW,QAAA;AACpC,IAAA,IAAA,CAAK,QAAQ,OAAA,CAAQ,IAAA;AAErB,IAAA,IAAI;AACA,MAAA,IAAA,CAAK,gBAAA,GAAmB,iBAAA,CAAkB,OAAA,CAAQ,UAAU,CAAA;AAAA,IAChE,SAAS,CAAA,EAAG;AACR,MAAA,MAAM,IAAI,KAAA,CAAM,gCAAA,EAAkC,EAAE,KAAA,EAAO,GAAG,CAAA;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AAA,GAAA,CAAI,KAAA,CAAM,2BAA2B,CAAC,CAAA;AACtC,QAAA,IAAA,CAAK,YAAA,CAAa;AAAA,UACd,IAAA,EAAM;AAAA,SACT,CAAA;AACD,QAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,MACjB,CAAC,CAAA;AAAA,IACT,GAAG,QAAQ,CAAA;AAAA,EACf;AAAA,EAEA,aAAa,QAAA,EAAqB;AAC9B,IAAA,IAAA,CAAK,OAAO,KAAA,GAAQ,QAAA;AAAA,EACxB;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"KeycloakAuthPluginImpl.js","sources":["KeycloakAuthPluginImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { reactive } from \"@conterra/reactivity-core\";\nimport { AuthState, LoginBehavior } from \"@open-pioneer/authentication\";\nimport { createLogger, destroyResource, Resource } from \"@open-pioneer/core\";\nimport { NotificationService } from \"@open-pioneer/notifier\";\nimport {\n PackageIntl,\n Service,\n ServiceOptions,\n DECLARE_SERVICE_INTERFACE\n} from \"@open-pioneer/runtime\";\nimport Keycloak, { KeycloakLogoutOptions } from \"keycloak-js\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { KeycloakAuthPlugin } from \"./api\";\nimport { getKeycloakConfig, ResolvedKeycloakOptions } from \"./getKeycloakConfig\";\n\nconst LOG = createLogger(sourceId);\n\ninterface References {\n notifier: NotificationService;\n}\n\nexport class KeycloakAuthPluginImpl implements Service, KeycloakAuthPlugin {\n declare [DECLARE_SERVICE_INTERFACE]: \"authentication-keycloak.KeycloakAuthPlugin\";\n\n #notifier: NotificationService;\n #intl: PackageIntl;\n #keycloakOptions: ResolvedKeycloakOptions;\n #keycloak: Keycloak;\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n #timerId: any;\n #watcher: Resource | undefined;\n\n #state = reactive<AuthState>({\n kind: \"pending\"\n });\n\n constructor(options: ServiceOptions<References>) {\n this.#notifier = options.references.notifier;\n this.#intl = options.intl;\n\n try {\n this.#keycloakOptions = getKeycloakConfig(options.properties);\n } catch (e) {\n throw new Error(\"Invalid keycloak configuration\", { cause: e });\n }\n\n try {\n this.#keycloak = new Keycloak(this.#keycloakOptions.config);\n } catch (e) {\n throw new Error(\"Failed to construct keycloak instance\", { cause: e });\n }\n this.#init().catch((e) => {\n this.#updateState({\n kind: \"error\",\n error: e\n });\n this.#notifier.notify({\n level: \"error\",\n title: this.#intl.formatMessage({\n id: \"loginFailed.title\"\n }),\n message: this.#intl.formatMessage({\n id: \"loginFailed.message\"\n })\n });\n\n LOG.error(\"Failed to check if user is authenticated\", e);\n });\n }\n\n destroy() {\n clearInterval(this.#timerId);\n this.#watcher = destroyResource(this.#watcher);\n this.#timerId = undefined;\n }\n\n getAuthState(): AuthState {\n return this.#state.value;\n }\n\n getLoginBehavior(): LoginBehavior {\n const doLogin = () => {\n const options = this.#keycloakOptions.loginOptions;\n LOG.debug(\"Login with options\", options);\n this.#keycloak.login(options);\n };\n return {\n kind: \"effect\",\n login: doLogin\n };\n }\n\n logout(options?: Partial<KeycloakLogoutOptions>) {\n const logoutOptions = {\n ...this.#keycloakOptions.logoutOptions,\n ...options\n };\n LOG.debug(\"Logout with options\", logoutOptions);\n this.#keycloak.logout(logoutOptions);\n }\n\n async #init() {\n const { initOptions, refreshOptions } = this.#keycloakOptions;\n\n let isAuthenticated: boolean;\n try {\n LOG.debug(\"Init with options\", initOptions);\n isAuthenticated = await this.#keycloak.init(initOptions);\n } catch (e) {\n // Note: keycloak.init() can also throw an exception, in addition to a rejected promise.\n // It may also just throw a string..\n const error = typeof e === \"string\" ? new Error(e) : e;\n\n // oxlint-disable-next-line preserve-caught-error\n throw new Error(\"Failed to initialize keycloak session\", { cause: error });\n }\n\n if (isAuthenticated) {\n this.#updateState({\n kind: \"authenticated\",\n sessionInfo: {\n userId: this.#keycloak.subject ? this.#keycloak.subject : \"undefined\",\n userName: this.#keycloak.idTokenParsed?.preferred_username,\n attributes: {\n keycloak: this.#keycloak,\n familyName: this.#keycloak.idTokenParsed?.family_name,\n givenName: this.#keycloak.idTokenParsed?.given_name,\n userName: this.#keycloak.idTokenParsed?.preferred_username\n }\n }\n });\n\n LOG.debug(`User ${this.#keycloak.subject} is authenticated`);\n\n if (refreshOptions.autoRefresh) {\n LOG.debug(\"Starting auto-refresh\", refreshOptions);\n this.__refresh(refreshOptions.interval, refreshOptions.timeLeft);\n }\n } else {\n this.#updateState({\n kind: \"not-authenticated\"\n });\n LOG.debug(\"User is not authenticated\");\n }\n }\n\n // Mocked in test (must stay on the prototype so `vi.spyOn` can replace it;\n // a private `#` method would not be spyable).\n __refresh(interval: number, timeLeft: number) {\n clearInterval(this.#timerId);\n this.#timerId = setInterval(() => {\n LOG.debug(\"Checking token validity\");\n this.#keycloak\n .updateToken(timeLeft)\n .then((refreshed) => {\n if (refreshed) {\n LOG.debug(\"Token refreshed successfully\");\n } else {\n LOG.debug(\"Token is still valid\");\n }\n })\n .catch((e) => {\n LOG.error(\"Failed to refresh token\", e);\n this.#updateState({\n kind: \"not-authenticated\"\n });\n this.destroy();\n });\n }, interval);\n }\n\n #updateState(newState: AuthState) {\n this.#state.value = newState;\n }\n}\n"],"names":[],"mappings":";;;;;;AAkBA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAM1B,MAAM,sBAAA,CAA8D;AAAA,EAGvE,SAAA;AAAA,EACA,KAAA;AAAA,EACA,gBAAA;AAAA,EACA,SAAA;AAAA;AAAA,EAGA,QAAA;AAAA,EACA,QAAA;AAAA,EAEA,SAAS,QAAA,CAAoB;AAAA,IACzB,IAAA,EAAM;AAAA,GACT,CAAA;AAAA,EAED,YAAY,OAAA,EAAqC;AAC7C,IAAA,IAAA,CAAK,SAAA,GAAY,QAAQ,UAAA,CAAW,QAAA;AACpC,IAAA,IAAA,CAAK,QAAQ,OAAA,CAAQ,IAAA;AAErB,IAAA,IAAI;AACA,MAAA,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AA,CAAI,MAAM,8BAA8B,CAAA;AAAA,QAC5C,CAAA,MAAO;AACH,UAAA,GAAA,CAAI,MAAM,sBAAsB,CAAA;AAAA,QACpC;AAAA,MACJ,CAAC,CAAA,CACA,KAAA,CAAM,CAAC,CAAA,KAAM;AACV,QAAA,GAAA,CAAI,KAAA,CAAM,2BAA2B,CAAC,CAAA;AACtC,QAAA,IAAA,CAAK,YAAA,CAAa;AAAA,UACd,IAAA,EAAM;AAAA,SACT,CAAA;AACD,QAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,MACjB,CAAC,CAAA;AAAA,IACT,GAAG,QAAQ,CAAA;AAAA,EACf;AAAA,EAEA,aAAa,QAAA,EAAqB;AAC9B,IAAA,IAAA,CAAK,OAAO,KAAA,GAAQ,QAAA;AAAA,EACxB;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-info.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"source-info.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/getKeycloakConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getKeycloakConfig.js","sources":["getKeycloakConfig.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createLogger } from \"@open-pioneer/core\";\nimport type {\n KeycloakConfig,\n KeycloakInitOptions,\n KeycloakLoginOptions,\n KeycloakLogoutOptions\n} from \"keycloak-js\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport type { KeycloakProperties, RefreshOptions } from \"./api\";\nconst LOG = createLogger(sourceId);\n\nconst DEFAULT_REFRESH_OPTS = {\n autoRefresh: true,\n interval: 10000,\n timeLeft: 60\n} as const;\n\nconst DEFAULT_INIT_OPTS = {\n onLoad: \"check-sso\",\n pkceMethod: \"S256\"\n} as const;\n\nexport type ResolvedRefreshOptions = Required<RefreshOptions>;\n\nexport interface ResolvedKeycloakOptions {\n config: KeycloakConfig;\n initOptions: KeycloakInitOptions;\n refreshOptions: ResolvedRefreshOptions;\n loginOptions: Partial<KeycloakLoginOptions>;\n logoutOptions: Partial<KeycloakLogoutOptions>;\n}\n\n/**\n * Parses the user supplied package properties.\n */\nexport function getKeycloakConfig(\n properties: Partial<KeycloakProperties>\n): ResolvedKeycloakOptions {\n const { keycloakOptions } = properties;\n if (!keycloakOptions) {\n throw new Error(\n `KeycloakOptions not found: The Keycloak configuration options are required by the plugin to perform login and logout operations`\n );\n }\n const {\n refreshOptions,\n keycloakInitOptions,\n keycloakConfig,\n keycloakLoginOptions,\n keycloakLogoutOptions\n } = keycloakOptions;\n return {\n config: getConfig(keycloakConfig),\n refreshOptions: getRefreshOptions(refreshOptions),\n initOptions: getInitOptions(keycloakInitOptions),\n loginOptions: getLoginOptions(keycloakLoginOptions),\n logoutOptions: getLogoutOptions(keycloakLogoutOptions)\n };\n}\n\nfunction getConfig(keycloakConfig: KeycloakConfig | undefined): KeycloakConfig {\n if (!keycloakConfig || isObjectEmpty(keycloakConfig)) {\n throw new Error(\n `KeycloakConfig not found: The Keycloak configuration options are required by the plugin to perform login and logout operations`\n );\n }\n return { ...keycloakConfig };\n}\n\nfunction getRefreshOptions(refreshOptions: RefreshOptions | undefined): ResolvedRefreshOptions {\n if (!refreshOptions || isObjectEmpty(refreshOptions)) {\n LOG.info(`Using default options for keycloak token refresh`, DEFAULT_REFRESH_OPTS);\n }\n return {\n ...DEFAULT_REFRESH_OPTS,\n ...refreshOptions\n };\n}\n\nfunction getInitOptions(keycloakInitOptions: KeycloakInitOptions | undefined): KeycloakInitOptions {\n if (!keycloakInitOptions || isObjectEmpty(keycloakInitOptions)) {\n LOG.info(`Using default options for keycloak init`, DEFAULT_INIT_OPTS);\n }\n return {\n ...DEFAULT_INIT_OPTS,\n ...keycloakInitOptions\n };\n}\n\nfunction getLoginOptions(\n keycloakLoginOptions: Partial<KeycloakLoginOptions> | undefined\n): Partial<KeycloakLoginOptions> {\n return {\n redirectUri: undefined, // backwards-compat; unsure if needed\n ...keycloakLoginOptions\n };\n}\n\nfunction getLogoutOptions(\n keycloakLogoutOptions: Partial<KeycloakLogoutOptions> | undefined\n): Partial<KeycloakLogoutOptions> {\n return {\n redirectUri: undefined, // backwards-compat; unsure if needed\n ...keycloakLogoutOptions\n };\n}\n\nconst isObjectEmpty = (objectName: unknown) => {\n return objectName && Object.keys(objectName).length === 0 && objectName.constructor === Object;\n};\n"],"names":[],"mappings":";;;AAYA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,oBAAA,GAAuB;AAAA,EACzB,WAAA,EAAa,IAAA;AAAA,EACb,QAAA,EAAU,GAAA;AAAA,EACV,QAAA,EAAU;AACd,CAAA;AAEA,MAAM,iBAAA,GAAoB;AAAA,EACtB,MAAA,EAAQ,WAAA;AAAA,EACR,UAAA,EAAY;AAChB,CAAA;AAeO,SAAS,kBACZ,UAAA,EACuB;AACvB,EAAA,MAAM,EAAE,iBAAgB,GAAI,UAAA;AAC5B,EAAA,IAAI,CAAC,eAAA,EAAiB;AAClB,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,+HAAA;AAAA,KACJ;AAAA,EACJ;AACA,EAAA,MAAM;AAAA,IACF,cAAA;AAAA,IACA,mBAAA;AAAA,IACA,cAAA;AAAA,IACA,oBAAA;AAAA,IACA;AAAA,GACJ,GAAI,eAAA;AACJ,EAAA,OAAO;AAAA,IACH,MAAA,EAAQ,UAAU,cAAc,CAAA;AAAA,IAChC,cAAA,EAAgB,kBAAkB,cAAc,CAAA;AAAA,IAChD,WAAA,EAAa,eAAe,mBAAmB,CAAA;AAAA,IAC/C,YAAA,EAAc,gBAAgB,oBAAoB,CAAA;AAAA,IAClD,aAAA,EAAe,iBAAiB,qBAAqB;AAAA,GACzD;AACJ;AAEA,SAAS,UAAU,cAAA,EAA4D;AAC3E,EAAA,IAAI,CAAC,cAAA,IAAkB,aAAA,CAAc,cAAc,CAAA,EAAG;AAClD,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,8HAAA;AAAA,KACJ;AAAA,EACJ;AACA,EAAA,OAAO,EAAE,GAAG,cAAA,EAAe;AAC/B;AAEA,SAAS,kBAAkB,cAAA,EAAoE;AAC3F,EAAA,IAAI,CAAC,cAAA,IAAkB,aAAA,CAAc,cAAc,CAAA,EAAG;AAClD,IAAA,GAAA,CAAI,IAAA,CAAK,oDAAoD,oBAAoB,CAAA;AAAA,EACrF;AACA,EAAA,OAAO;AAAA,IACH,GAAG,oBAAA;AAAA,IACH,GAAG;AAAA,GACP;AACJ;AAEA,SAAS,eAAe,mBAAA,EAA2E;AAC/F,EAAA,IAAI,CAAC,mBAAA,IAAuB,aAAA,CAAc,mBAAmB,CAAA,EAAG;AAC5D,IAAA,GAAA,CAAI,IAAA,CAAK,2CAA2C,iBAAiB,CAAA;AAAA,EACzE;AACA,EAAA,OAAO;AAAA,IACH,GAAG,iBAAA;AAAA,IACH,GAAG;AAAA,GACP;AACJ;AAEA,SAAS,gBACL,oBAAA,EAC6B;AAC7B,EAAA,OAAO;AAAA,IACH,WAAA,EAAa,MAAA;AAAA;AAAA,IACb,GAAG;AAAA,GACP;AACJ;AAEA,SAAS,iBACL,qBAAA,EAC8B;AAC9B,EAAA,OAAO;AAAA,IACH,WAAA,EAAa,MAAA;AAAA;AAAA,IACb,GAAG;AAAA,GACP;AACJ;AAEA,MAAM,aAAA,GAAgB,CAAC,UAAA,KAAwB;AAC3C,EAAA,OAAO,UAAA,IAAc,OAAO,IAAA,CAAK,UAAU,EAAE,MAAA,KAAW,CAAA,IAAK,WAAW,WAAA,KAAgB,MAAA;AAC5F,CAAA
|
|
1
|
+
{"version":3,"file":"getKeycloakConfig.js","sources":["getKeycloakConfig.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createLogger } from \"@open-pioneer/core\";\nimport type {\n KeycloakConfig,\n KeycloakInitOptions,\n KeycloakLoginOptions,\n KeycloakLogoutOptions\n} from \"keycloak-js\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport type { KeycloakProperties, RefreshOptions } from \"./api\";\nconst LOG = createLogger(sourceId);\n\nconst DEFAULT_REFRESH_OPTS = {\n autoRefresh: true,\n interval: 10000,\n timeLeft: 60\n} as const;\n\nconst DEFAULT_INIT_OPTS = {\n onLoad: \"check-sso\",\n pkceMethod: \"S256\"\n} as const;\n\nexport type ResolvedRefreshOptions = Required<RefreshOptions>;\n\nexport interface ResolvedKeycloakOptions {\n config: KeycloakConfig;\n initOptions: KeycloakInitOptions;\n refreshOptions: ResolvedRefreshOptions;\n loginOptions: Partial<KeycloakLoginOptions>;\n logoutOptions: Partial<KeycloakLogoutOptions>;\n}\n\n/**\n * Parses the user supplied package properties.\n */\nexport function getKeycloakConfig(\n properties: Partial<KeycloakProperties>\n): ResolvedKeycloakOptions {\n const { keycloakOptions } = properties;\n if (!keycloakOptions) {\n throw new Error(\n `KeycloakOptions not found: The Keycloak configuration options are required by the plugin to perform login and logout operations`\n );\n }\n const {\n refreshOptions,\n keycloakInitOptions,\n keycloakConfig,\n keycloakLoginOptions,\n keycloakLogoutOptions\n } = keycloakOptions;\n return {\n config: getConfig(keycloakConfig),\n refreshOptions: getRefreshOptions(refreshOptions),\n initOptions: getInitOptions(keycloakInitOptions),\n loginOptions: getLoginOptions(keycloakLoginOptions),\n logoutOptions: getLogoutOptions(keycloakLogoutOptions)\n };\n}\n\nfunction getConfig(keycloakConfig: KeycloakConfig | undefined): KeycloakConfig {\n if (!keycloakConfig || isObjectEmpty(keycloakConfig)) {\n throw new Error(\n `KeycloakConfig not found: The Keycloak configuration options are required by the plugin to perform login and logout operations`\n );\n }\n return { ...keycloakConfig };\n}\n\nfunction getRefreshOptions(refreshOptions: RefreshOptions | undefined): ResolvedRefreshOptions {\n if (!refreshOptions || isObjectEmpty(refreshOptions)) {\n LOG.info(`Using default options for keycloak token refresh`, DEFAULT_REFRESH_OPTS);\n }\n return {\n ...DEFAULT_REFRESH_OPTS,\n ...refreshOptions\n };\n}\n\nfunction getInitOptions(keycloakInitOptions: KeycloakInitOptions | undefined): KeycloakInitOptions {\n if (!keycloakInitOptions || isObjectEmpty(keycloakInitOptions)) {\n LOG.info(`Using default options for keycloak init`, DEFAULT_INIT_OPTS);\n }\n return {\n ...DEFAULT_INIT_OPTS,\n ...keycloakInitOptions\n };\n}\n\nfunction getLoginOptions(\n keycloakLoginOptions: Partial<KeycloakLoginOptions> | undefined\n): Partial<KeycloakLoginOptions> {\n return {\n redirectUri: undefined, // backwards-compat; unsure if needed\n ...keycloakLoginOptions\n };\n}\n\nfunction getLogoutOptions(\n keycloakLogoutOptions: Partial<KeycloakLogoutOptions> | undefined\n): Partial<KeycloakLogoutOptions> {\n return {\n redirectUri: undefined, // backwards-compat; unsure if needed\n ...keycloakLogoutOptions\n };\n}\n\nconst isObjectEmpty = (objectName: unknown) => {\n return objectName && Object.keys(objectName).length === 0 && objectName.constructor === Object;\n};\n"],"names":[],"mappings":";;;AAYA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,oBAAA,GAAuB;AAAA,EACzB,WAAA,EAAa,IAAA;AAAA,EACb,QAAA,EAAU,GAAA;AAAA,EACV,QAAA,EAAU;AACd,CAAA;AAEA,MAAM,iBAAA,GAAoB;AAAA,EACtB,MAAA,EAAQ,WAAA;AAAA,EACR,UAAA,EAAY;AAChB,CAAA;AAeO,SAAS,kBACZ,UAAA,EACuB;AACvB,EAAA,MAAM,EAAE,iBAAgB,GAAI,UAAA;AAC5B,EAAA,IAAI,CAAC,eAAA,EAAiB;AAClB,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,+HAAA;AAAA,KACJ;AAAA,EACJ;AACA,EAAA,MAAM;AAAA,IACF,cAAA;AAAA,IACA,mBAAA;AAAA,IACA,cAAA;AAAA,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AAA;AAAA,IACb,GAAG;AAAA,GACP;AACJ;AAEA,MAAM,aAAA,GAAgB,CAAC,UAAA,KAAwB;AAC3C,EAAA,OAAO,UAAA,IAAc,OAAO,IAAA,CAAK,UAAU,EAAE,MAAA,KAAW,CAAA,IAAK,WAAW,WAAA,KAAgB,MAAA;AAC5F,CAAA;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/authentication-keycloak",
|
|
4
|
-
"version": "4.8.0
|
|
4
|
+
"version": "4.8.0",
|
|
5
5
|
"description": "Implements authentication against Keycloak servers.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@conterra/reactivity-core": "^0.8.8",
|
|
18
|
-
"@open-pioneer/authentication": "4.8.0
|
|
19
|
-
"@open-pioneer/core": "4.8.0
|
|
20
|
-
"@open-pioneer/notifier": "4.8.0
|
|
21
|
-
"@open-pioneer/runtime": "4.8.0
|
|
18
|
+
"@open-pioneer/authentication": "4.8.0",
|
|
19
|
+
"@open-pioneer/core": "4.8.0",
|
|
20
|
+
"@open-pioneer/notifier": "4.8.0",
|
|
21
|
+
"@open-pioneer/runtime": "4.8.0",
|
|
22
22
|
"keycloak-js": "^26.2.4"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|