@samhammer/authentication-vue 1.3.2 → 2.0.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.
@@ -1,8 +1,8 @@
1
- import Vue from 'vue';
1
+ import Emittery from "emittery";
2
2
  export declare enum AuthEventNames {
3
3
  isAlreadyAuthenticated = "isAlreadyAuthenticated",
4
4
  isGuestAuthenticated = "isGuestAuthenticated",
5
5
  loginRequired = "loginRequired",
6
6
  permissionDenied = "permissionDenied"
7
7
  }
8
- export declare const AuthEvents: import("vue/types/vue").CombinedVueInstance<Vue, object, object, object, Record<never, any>>;
8
+ export declare const AuthEvents: Emittery<Record<PropertyKey, any>, Record<PropertyKey, any> & import("emittery").OmnipresentEventData, import("emittery").DatalessEventNames<Record<PropertyKey, any>>>;
package/lib/AuthEvents.js CHANGED
@@ -1,4 +1,4 @@
1
- import Vue from 'vue';
1
+ import Emittery from "emittery";
2
2
  export var AuthEventNames;
3
3
  (function (AuthEventNames) {
4
4
  AuthEventNames["isAlreadyAuthenticated"] = "isAlreadyAuthenticated";
@@ -6,5 +6,4 @@ export var AuthEventNames;
6
6
  AuthEventNames["loginRequired"] = "loginRequired";
7
7
  AuthEventNames["permissionDenied"] = "permissionDenied";
8
8
  })(AuthEventNames || (AuthEventNames = {}));
9
- export var AuthEvents = new Vue();
10
- //# sourceMappingURL=AuthEvents.js.map
9
+ export const AuthEvents = new Emittery();
@@ -1,7 +1,8 @@
1
1
  export interface AuthOptions {
2
- apiClientId: string;
3
- appClientId: string;
4
- authUrl: string;
5
- realm: string;
2
+ apiClientId?: string;
3
+ appClientId?: string;
4
+ guestClientId?: string;
5
+ authUrl?: string;
6
+ realm?: string;
6
7
  guestRoles?: string[];
7
8
  }
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=AuthOptions.js.map
@@ -1,4 +1,4 @@
1
- import { AuthOptions } from './AuthOptions';
1
+ import type { AuthOptions } from "./AuthOptions";
2
2
  export declare class AuthPlugin {
3
3
  private authOptions;
4
4
  private keycloak;
@@ -7,8 +7,11 @@ export declare class AuthPlugin {
7
7
  get authenticated(): boolean;
8
8
  get isGuest(): boolean;
9
9
  getToken(): Promise<string>;
10
- initOnce: (authOptions: AuthOptions) => Promise<boolean>;
10
+ initOnce: (authOptions: AuthOptions) => Promise<void>;
11
11
  loginGuest(): Promise<void>;
12
12
  login(idp: string): Promise<void>;
13
+ createLoginUrl(idp: string, customRedirectUri?: string): string;
14
+ createLogoutUrl(customRedirectUri?: string): string;
15
+ update(): Promise<void>;
13
16
  logout(redirectUri: string): Promise<void>;
14
17
  }
package/lib/AuthPlugin.js CHANGED
@@ -1,465 +1,239 @@
1
- import { __awaiter, __generator } from "tslib";
2
- import Keycloak from 'keycloak-js';
3
- import once from 'lodash/once';
4
- import { includes, throttle } from 'lodash';
5
- import LocalStorageUtils from './LocalStorageUtils';
6
- import { v4 as uuidv4 } from 'uuid';
7
- import { AuthEvents, AuthEventNames } from './AuthEvents';
8
- var AuthPlugin = /** @class */ (function () {
9
- function AuthPlugin() {
10
- var _this = this;
11
- Object.defineProperty(this, "authOptions", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: void 0
16
- });
17
- Object.defineProperty(this, "keycloak", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: new KeycloakPlugin()
22
- });
23
- Object.defineProperty(this, "guest", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: new GuestPlugin()
28
- });
29
- Object.defineProperty(this, "initOnce", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: once(function (authOptions) { return __awaiter(_this, void 0, void 0, function () {
34
- var authenticated, _a;
35
- return __generator(this, function (_b) {
36
- switch (_b.label) {
37
- case 0:
38
- this.authOptions = authOptions;
39
- _a = this.guest.init(this.authOptions);
40
- if (_a) return [3 /*break*/, 2];
41
- return [4 /*yield*/, this.keycloak.init(this.authOptions)];
42
- case 1:
43
- _a = (_b.sent());
44
- _b.label = 2;
45
- case 2:
46
- authenticated = _a;
47
- if (authenticated) {
48
- AuthEvents.$emit(AuthEventNames.isAlreadyAuthenticated);
49
- }
50
- return [2 /*return*/, authenticated];
51
- }
52
- });
53
- }); })
54
- });
1
+ import Keycloak from "keycloak-js";
2
+ import once from "lodash/once";
3
+ import { includes, throttle } from "lodash";
4
+ import LocalStorageUtils from "./LocalStorageUtils";
5
+ import { v4 as uuidv4 } from "uuid";
6
+ import { AuthEvents, AuthEventNames } from "./AuthEvents";
7
+ export class AuthPlugin {
8
+ authOptions;
9
+ keycloak = new KeycloakPlugin();
10
+ guest = new GuestPlugin();
11
+ hasRole(roleName, apiClientId) {
12
+ if (!roleName) {
13
+ return true;
14
+ }
15
+ return this.guest.hasRole(roleName) || this.keycloak.hasRole(this.authOptions, roleName, apiClientId);
55
16
  }
56
- Object.defineProperty(AuthPlugin.prototype, "hasRole", {
57
- enumerable: false,
58
- configurable: true,
59
- writable: true,
60
- value: function (roleName, apiClientId) {
61
- if (!roleName) {
62
- return true;
63
- }
64
- return this.guest.hasRole(roleName) || this.keycloak.hasRole(this.authOptions, roleName, apiClientId);
65
- }
66
- });
67
- Object.defineProperty(AuthPlugin.prototype, "authenticated", {
68
- get: function () {
69
- return this.guest.authenticated || this.keycloak.authenticated;
70
- },
71
- enumerable: false,
72
- configurable: true
73
- });
74
- Object.defineProperty(AuthPlugin.prototype, "isGuest", {
75
- get: function () {
76
- return this.guest.authenticated;
77
- },
78
- enumerable: false,
79
- configurable: true
80
- });
81
- Object.defineProperty(AuthPlugin.prototype, "getToken", {
82
- enumerable: false,
83
- configurable: true,
84
- writable: true,
85
- value: function () {
86
- return __awaiter(this, void 0, void 0, function () {
87
- return __generator(this, function (_a) {
88
- return [2 /*return*/, this.guest.authenticated ? this.guest.getGuestId() : this.keycloak.getToken()];
89
- });
90
- });
17
+ get authenticated() {
18
+ return this.guest.authenticated || this.keycloak.authenticated;
19
+ }
20
+ get isGuest() {
21
+ return this.guest.authenticated;
22
+ }
23
+ async getToken() {
24
+ return this.guest.authenticated ? this.guest.getGuestId() : this.keycloak.getToken();
25
+ }
26
+ initOnce = once(async (authOptions) => {
27
+ this.authOptions = authOptions;
28
+ const authenticated = this.guest.init(this.authOptions) || (await this.keycloak.init(this.authOptions));
29
+ if (authenticated) {
30
+ AuthEvents.emit(AuthEventNames.isAlreadyAuthenticated);
91
31
  }
92
32
  });
93
- Object.defineProperty(AuthPlugin.prototype, "loginGuest", {
94
- enumerable: false,
95
- configurable: true,
96
- writable: true,
97
- value: function () {
98
- return __awaiter(this, void 0, void 0, function () {
99
- return __generator(this, function (_a) {
100
- this.guest.login(this.authOptions);
101
- return [2 /*return*/];
102
- });
103
- });
33
+ async loginGuest() {
34
+ if (!this.authOptions)
35
+ throw new Error("Init has to be called first");
36
+ this.guest.login(this.authOptions);
37
+ }
38
+ async login(idp) {
39
+ await this.keycloak.login(window.location.href, idp);
40
+ }
41
+ createLoginUrl(idp, customRedirectUri) {
42
+ const redirectUri = customRedirectUri ? customRedirectUri : window.location.href;
43
+ return this.keycloak.createLoginUrl(redirectUri, idp);
44
+ }
45
+ createLogoutUrl(customRedirectUri) {
46
+ const redirectUri = customRedirectUri ? customRedirectUri : window.location.href;
47
+ return this.keycloak.createLogoutUrl(redirectUri);
48
+ }
49
+ async update() {
50
+ const authenticated = await this.keycloak.initKeycloak();
51
+ if (authenticated) {
52
+ AuthEvents.emit(AuthEventNames.isAlreadyAuthenticated);
104
53
  }
105
- });
106
- Object.defineProperty(AuthPlugin.prototype, "login", {
107
- enumerable: false,
108
- configurable: true,
109
- writable: true,
110
- value: function (idp) {
111
- return __awaiter(this, void 0, void 0, function () {
112
- return __generator(this, function (_a) {
113
- switch (_a.label) {
114
- case 0: return [4 /*yield*/, this.keycloak.login(window.location.href, idp)];
115
- case 1:
116
- _a.sent();
117
- return [2 /*return*/];
118
- }
119
- });
120
- });
54
+ }
55
+ async logout(redirectUri) {
56
+ if (this.guest.authenticated) {
57
+ this.guest.logout();
58
+ return;
121
59
  }
122
- });
123
- Object.defineProperty(AuthPlugin.prototype, "logout", {
124
- enumerable: false,
125
- configurable: true,
126
- writable: true,
127
- value: function (redirectUri) {
128
- return __awaiter(this, void 0, void 0, function () {
129
- return __generator(this, function (_a) {
130
- switch (_a.label) {
131
- case 0:
132
- if (this.guest.authenticated) {
133
- this.guest.logout();
134
- return [2 /*return*/];
135
- }
136
- return [4 /*yield*/, this.keycloak.logout(redirectUri)];
137
- case 1:
138
- _a.sent();
139
- return [2 /*return*/];
140
- }
141
- });
142
- });
60
+ await this.keycloak.logout(redirectUri);
61
+ }
62
+ }
63
+ class KeycloakPlugin {
64
+ pluginState;
65
+ hasRole(authOptions, roleName, apiClientId) {
66
+ if (!authOptions)
67
+ return false;
68
+ if (this.pluginState) {
69
+ const resource = !apiClientId ? authOptions.apiClientId : apiClientId;
70
+ return this.pluginState.keycloak.hasResourceRole(roleName, resource);
143
71
  }
144
- });
145
- return AuthPlugin;
146
- }());
147
- export { AuthPlugin };
148
- var KeycloakPlugin = /** @class */ (function () {
149
- function KeycloakPlugin() {
150
- var _this = this;
151
- Object.defineProperty(this, "keycloak", {
152
- enumerable: true,
153
- configurable: true,
154
- writable: true,
155
- value: null
156
- });
157
- Object.defineProperty(this, "accessTokenKey", {
158
- enumerable: true,
159
- configurable: true,
160
- writable: true,
161
- value: null
162
- });
163
- Object.defineProperty(this, "refreshTokenKey", {
164
- enumerable: true,
165
- configurable: true,
166
- writable: true,
167
- value: null
168
- });
169
- Object.defineProperty(this, "idTokenKey", {
170
- enumerable: true,
171
- configurable: true,
172
- writable: true,
173
- value: null
174
- });
175
- // this method ensures that we have only one refresh call even when it gets executed multiple times in paralell
176
- // NOTE: time for 'throttle wait' (ms) must be lower then 'token minValidity' (sec)
177
- Object.defineProperty(this, "refreshSingle", {
178
- enumerable: true,
179
- configurable: true,
180
- writable: true,
181
- value: throttle(function () { return _this.refresh(10); }, 5000, { trailing: false })
182
- });
72
+ return false;
183
73
  }
184
- Object.defineProperty(KeycloakPlugin.prototype, "hasRole", {
185
- enumerable: false,
186
- configurable: true,
187
- writable: true,
188
- value: function (authOptions, roleName, apiClientId) {
189
- if (this.keycloak) {
190
- var resource = !apiClientId ? authOptions.apiClientId : apiClientId;
191
- return this.keycloak.hasResourceRole(roleName, resource);
192
- }
74
+ get authenticated() {
75
+ if (!this.pluginState?.keycloak) {
193
76
  return false;
194
77
  }
195
- });
196
- Object.defineProperty(KeycloakPlugin.prototype, "authenticated", {
197
- get: function () {
198
- if (!this.keycloak) {
78
+ return this.pluginState.keycloak.authenticated ?? false;
79
+ }
80
+ async getToken() {
81
+ if (!this.pluginState?.keycloak || !this.pluginState.keycloak.refreshToken) {
82
+ return "";
83
+ }
84
+ await this.refreshSingle();
85
+ return this.pluginState.keycloak.token ?? "";
86
+ }
87
+ async init(authOptions) {
88
+ try {
89
+ if (!authOptions.appClientId || !authOptions.authUrl || !authOptions.realm) {
199
90
  return false;
200
91
  }
201
- return this.keycloak.authenticated;
202
- },
203
- enumerable: false,
204
- configurable: true
205
- });
206
- Object.defineProperty(KeycloakPlugin.prototype, "getToken", {
207
- enumerable: false,
208
- configurable: true,
209
- writable: true,
210
- value: function () {
211
- return __awaiter(this, void 0, void 0, function () {
212
- return __generator(this, function (_a) {
213
- switch (_a.label) {
214
- case 0:
215
- if (!this.keycloak || !this.keycloak.refreshToken) {
216
- return [2 /*return*/, null];
217
- }
218
- return [4 /*yield*/, this.refreshSingle()];
219
- case 1:
220
- _a.sent();
221
- return [2 /*return*/, this.keycloak.token];
222
- }
223
- });
224
- });
225
- }
226
- });
227
- Object.defineProperty(KeycloakPlugin.prototype, "init", {
228
- enumerable: false,
229
- configurable: true,
230
- writable: true,
231
- value: function (authOptions) {
232
- return __awaiter(this, void 0, void 0, function () {
233
- var authenticated, error_1;
234
- return __generator(this, function (_a) {
235
- switch (_a.label) {
236
- case 0:
237
- _a.trys.push([0, 2, , 3]);
238
- this.accessTokenKey = "".concat(authOptions.appClientId, "-accessToken");
239
- this.refreshTokenKey = "".concat(authOptions.appClientId, "-refreshToken");
240
- this.idTokenKey = "".concat(authOptions.appClientId, "-idToken");
241
- this.keycloak = new Keycloak({
242
- url: authOptions.authUrl,
243
- realm: authOptions.realm,
244
- clientId: authOptions.appClientId
245
- });
246
- this.keycloak.onAuthSuccess = this.onAuthSuccess.bind(this);
247
- this.keycloak.onAuthRefreshSuccess = this.onAuthRefreshSuccess.bind(this);
248
- this.keycloak.onTokenExpired = this.onTokenExpired.bind(this);
249
- return [4 /*yield*/, this.keycloak.init({
250
- flow: 'standard',
251
- timeSkew: 0,
252
- enableLogging: false,
253
- refreshToken: LocalStorageUtils.getItem(this.refreshTokenKey),
254
- token: LocalStorageUtils.getItem(this.accessTokenKey),
255
- idToken: LocalStorageUtils.getItem(this.idTokenKey)
256
- })];
257
- case 1:
258
- authenticated = _a.sent();
259
- if (authenticated) {
260
- console.debug('authenticated keycloak');
261
- }
262
- return [2 /*return*/, authenticated];
263
- case 2:
264
- error_1 = _a.sent();
265
- console.error('auth init failed', error_1);
266
- LocalStorageUtils.removeItem(this.refreshTokenKey);
267
- LocalStorageUtils.removeItem(this.accessTokenKey);
268
- LocalStorageUtils.removeItem(this.idTokenKey);
269
- return [2 /*return*/, false];
270
- case 3: return [2 /*return*/];
271
- }
272
- });
273
- });
274
- }
275
- });
276
- Object.defineProperty(KeycloakPlugin.prototype, "onAuthSuccess", {
277
- enumerable: false,
278
- configurable: true,
279
- writable: true,
280
- value: function () {
281
- LocalStorageUtils.setItem(this.refreshTokenKey, this.keycloak.refreshToken);
282
- LocalStorageUtils.setItem(this.accessTokenKey, this.keycloak.token);
283
- LocalStorageUtils.setItem(this.idTokenKey, this.keycloak.idToken);
284
- }
285
- });
286
- Object.defineProperty(KeycloakPlugin.prototype, "onAuthRefreshSuccess", {
287
- enumerable: false,
288
- configurable: true,
289
- writable: true,
290
- value: function () {
291
- LocalStorageUtils.setItem(this.refreshTokenKey, this.keycloak.refreshToken);
292
- LocalStorageUtils.setItem(this.accessTokenKey, this.keycloak.token);
293
- LocalStorageUtils.setItem(this.idTokenKey, this.keycloak.idToken);
294
- }
295
- });
296
- Object.defineProperty(KeycloakPlugin.prototype, "onTokenExpired", {
297
- enumerable: false,
298
- configurable: true,
299
- writable: true,
300
- value: function () {
301
- return __awaiter(this, void 0, void 0, function () {
302
- return __generator(this, function (_a) {
303
- // force refresh
304
- this.refresh(-1);
305
- return [2 /*return*/];
306
- });
307
- });
308
- }
309
- });
310
- Object.defineProperty(KeycloakPlugin.prototype, "login", {
311
- enumerable: false,
312
- configurable: true,
313
- writable: true,
314
- value: function (redirectUri, idp) {
315
- return __awaiter(this, void 0, void 0, function () {
316
- return __generator(this, function (_a) {
317
- switch (_a.label) {
318
- case 0:
319
- console.debug('login navigating to keycloak with returnUrl', redirectUri);
320
- return [4 /*yield*/, this.keycloak.login({ redirectUri: redirectUri, idpHint: idp })];
321
- case 1:
322
- _a.sent();
323
- return [2 /*return*/];
324
- }
325
- });
326
- });
327
- }
328
- });
329
- Object.defineProperty(KeycloakPlugin.prototype, "logout", {
330
- enumerable: false,
331
- configurable: true,
332
- writable: true,
333
- value: function (redirectUri) {
334
- return __awaiter(this, void 0, void 0, function () {
335
- return __generator(this, function (_a) {
336
- switch (_a.label) {
337
- case 0:
338
- console.debug('logout navigating to keycloak with returnUrl', redirectUri);
339
- LocalStorageUtils.removeItem(this.refreshTokenKey);
340
- LocalStorageUtils.removeItem(this.accessTokenKey);
341
- LocalStorageUtils.removeItem(this.idTokenKey);
342
- return [4 /*yield*/, this.keycloak.logout({ redirectUri: redirectUri })];
343
- case 1:
344
- _a.sent();
345
- return [2 /*return*/];
346
- }
347
- });
348
- });
349
- }
350
- });
351
- Object.defineProperty(KeycloakPlugin.prototype, "refresh", {
352
- enumerable: false,
353
- configurable: true,
354
- writable: true,
355
- value: function (minValidity) {
356
- return __awaiter(this, void 0, void 0, function () {
357
- var successful, error_2;
358
- return __generator(this, function (_a) {
359
- switch (_a.label) {
360
- case 0:
361
- _a.trys.push([0, 2, , 3]);
362
- return [4 /*yield*/, this.keycloak.updateToken(minValidity)];
363
- case 1:
364
- successful = _a.sent();
365
- if (successful) {
366
- console.debug('token refreshed');
367
- }
368
- return [3 /*break*/, 3];
369
- case 2:
370
- error_2 = _a.sent();
371
- console.error('token refresh failed', error_2 || 'token may be empty');
372
- return [3 /*break*/, 3];
373
- case 3: return [2 /*return*/];
374
- }
375
- });
92
+ const keycloak = new Keycloak({
93
+ url: authOptions.authUrl,
94
+ realm: authOptions.realm,
95
+ clientId: authOptions.appClientId
376
96
  });
97
+ this.pluginState = {
98
+ keycloak: keycloak,
99
+ accessTokenKey: `${authOptions.appClientId}-accessToken`,
100
+ refreshTokenKey: `${authOptions.appClientId}-refreshToken`,
101
+ idTokenKey: `${authOptions.appClientId}-idToken`
102
+ };
103
+ keycloak.onAuthSuccess = this.setLocalStorage.bind(this);
104
+ keycloak.onAuthRefreshSuccess = this.setLocalStorage.bind(this);
105
+ keycloak.onTokenExpired = this.onTokenExpired.bind(this);
106
+ return this.initKeycloak();
107
+ }
108
+ catch (error) {
109
+ console.error("auth init failed", error);
110
+ this.clearLocalStorage();
111
+ return false;
377
112
  }
378
- });
379
- return KeycloakPlugin;
380
- }());
381
- var GuestPlugin = /** @class */ (function () {
382
- function GuestPlugin() {
383
- Object.defineProperty(this, "guestKey", {
384
- enumerable: true,
385
- configurable: true,
386
- writable: true,
387
- value: null
388
- });
389
- Object.defineProperty(this, "guestId", {
390
- enumerable: true,
391
- configurable: true,
392
- writable: true,
393
- value: null
394
- });
395
- Object.defineProperty(this, "guestRoles", {
396
- enumerable: true,
397
- configurable: true,
398
- writable: true,
399
- value: []
400
- });
401
113
  }
402
- Object.defineProperty(GuestPlugin.prototype, "hasRole", {
403
- enumerable: false,
404
- configurable: true,
405
- writable: true,
406
- value: function (roleName) {
407
- return includes(this.guestRoles, roleName);
408
- }
409
- });
410
- Object.defineProperty(GuestPlugin.prototype, "authenticated", {
411
- get: function () {
412
- return this.guestId ? true : false;
413
- },
414
- enumerable: false,
415
- configurable: true
416
- });
417
- Object.defineProperty(GuestPlugin.prototype, "getGuestId", {
418
- enumerable: false,
419
- configurable: true,
420
- writable: true,
421
- value: function () {
422
- return this.guestId;
114
+ async initKeycloak() {
115
+ if (!this.pluginState)
116
+ throw new Error("Init has to be called first");
117
+ const authenticated = await this.pluginState.keycloak.init({
118
+ flow: "standard",
119
+ timeSkew: 0,
120
+ enableLogging: false,
121
+ refreshToken: LocalStorageUtils.getItem(this.pluginState.refreshTokenKey),
122
+ token: LocalStorageUtils.getItem(this.pluginState.accessTokenKey),
123
+ idToken: LocalStorageUtils.getItem(this.pluginState.idTokenKey)
124
+ });
125
+ if (authenticated) {
126
+ console.debug("authenticated keycloak");
423
127
  }
424
- });
425
- Object.defineProperty(GuestPlugin.prototype, "init", {
426
- enumerable: false,
427
- configurable: true,
428
- writable: true,
429
- value: function (authOptions) {
430
- this.guestKey = "".concat(authOptions.appClientId, "-guestId");
431
- this.guestId = LocalStorageUtils.getItem(this.guestKey);
432
- if (this.authenticated) {
433
- this.guestRoles = authOptions.guestRoles || ['User'];
434
- console.debug('authenticated guest');
128
+ return authenticated;
129
+ }
130
+ async onTokenExpired() {
131
+ // force refresh
132
+ this.refresh(-1);
133
+ }
134
+ async login(redirectUri, idp) {
135
+ console.debug("login navigating to keycloak with returnUrl", redirectUri);
136
+ if (!this.pluginState)
137
+ throw new Error("Init has to be called first");
138
+ await this.pluginState.keycloak.login({ redirectUri, idpHint: idp });
139
+ }
140
+ createLoginUrl(redirectUri, idp) {
141
+ console.debug("create loginUrl to keycloak with returnUrl", redirectUri);
142
+ if (!this.pluginState)
143
+ throw new Error("Init has to be called first");
144
+ return this.pluginState.keycloak.createLoginUrl({ redirectUri, idpHint: idp });
145
+ }
146
+ createLogoutUrl(redirectUri) {
147
+ console.debug("create logoutUrl to keycloak with returnUrl", redirectUri);
148
+ if (!this.pluginState)
149
+ throw new Error("Init has to be called first");
150
+ return this.pluginState.keycloak.createLogoutUrl({ redirectUri });
151
+ }
152
+ async logout(redirectUri) {
153
+ console.debug("logout navigating to keycloak with returnUrl", redirectUri);
154
+ this.clearLocalStorage();
155
+ if (!this.pluginState)
156
+ return;
157
+ await this.pluginState.keycloak.logout({ redirectUri });
158
+ }
159
+ setLocalStorage() {
160
+ if (!this.pluginState)
161
+ return;
162
+ LocalStorageUtils.setItem(this.pluginState.refreshTokenKey, this.pluginState.keycloak.refreshToken ?? "");
163
+ LocalStorageUtils.setItem(this.pluginState.accessTokenKey, this.pluginState.keycloak.token ?? "");
164
+ LocalStorageUtils.setItem(this.pluginState.idTokenKey, this.pluginState.keycloak.idToken ?? "");
165
+ }
166
+ clearLocalStorage() {
167
+ if (!this.pluginState)
168
+ return;
169
+ LocalStorageUtils.removeItem(this.pluginState.refreshTokenKey);
170
+ LocalStorageUtils.removeItem(this.pluginState.accessTokenKey);
171
+ LocalStorageUtils.removeItem(this.pluginState.idTokenKey);
172
+ }
173
+ async refresh(minValidity) {
174
+ try {
175
+ if (!this.pluginState)
176
+ return;
177
+ const successful = await this.pluginState.keycloak.updateToken(minValidity);
178
+ if (successful) {
179
+ console.debug("token refreshed");
435
180
  }
436
- return this.authenticated;
437
181
  }
438
- });
439
- Object.defineProperty(GuestPlugin.prototype, "login", {
440
- enumerable: false,
441
- configurable: true,
442
- writable: true,
443
- value: function (authOptions) {
444
- console.debug('login guest');
445
- this.guestId = uuidv4();
446
- LocalStorageUtils.setItem(this.guestKey, this.guestId);
447
- this.init(authOptions);
448
- AuthEvents.$emit(AuthEventNames.isGuestAuthenticated);
182
+ catch (error) {
183
+ console.error("token refresh failed", error || "token may be empty");
449
184
  }
450
- });
451
- Object.defineProperty(GuestPlugin.prototype, "logout", {
452
- enumerable: false,
453
- configurable: true,
454
- writable: true,
455
- value: function () {
456
- console.debug('logout guest');
457
- LocalStorageUtils.removeItem(this.guestKey);
458
- this.guestId = null;
459
- this.guestRoles = null;
460
- window.location.reload();
185
+ }
186
+ // this method ensures that we have only one refresh call even when it gets executed multiple times in paralell
187
+ // NOTE: time for 'throttle wait' (ms) must be lower then 'token minValidity' (sec)
188
+ refreshSingle = throttle(() => this.refresh(10), 5000, { trailing: false });
189
+ }
190
+ class GuestPlugin {
191
+ pluginState;
192
+ hasRole(roleName) {
193
+ if (!this.pluginState)
194
+ return false;
195
+ return includes(this.pluginState.guestRoles, roleName);
196
+ }
197
+ get authenticated() {
198
+ return this.pluginState?.guestId ? true : false;
199
+ }
200
+ getGuestId() {
201
+ return this.pluginState?.guestId ?? "";
202
+ }
203
+ init(authOptions) {
204
+ if (!authOptions.guestClientId) {
205
+ return false;
461
206
  }
462
- });
463
- return GuestPlugin;
464
- }());
465
- //# sourceMappingURL=AuthPlugin.js.map
207
+ const guestKey = `${authOptions.guestClientId}-guestId`;
208
+ const guestId = LocalStorageUtils.getItem(guestKey);
209
+ let guestRoles = [];
210
+ if (this.authenticated) {
211
+ guestRoles = authOptions.guestRoles || ["User"];
212
+ console.debug("authenticated guest");
213
+ }
214
+ this.pluginState = {
215
+ guestKey: guestKey,
216
+ guestId: guestId,
217
+ guestRoles: guestRoles
218
+ };
219
+ return this.authenticated;
220
+ }
221
+ login(authOptions) {
222
+ console.debug("login guest");
223
+ if (!this.pluginState)
224
+ throw new Error("Init has to be called first");
225
+ this.pluginState.guestId = uuidv4();
226
+ LocalStorageUtils.setItem(this.pluginState.guestKey, this.pluginState.guestId);
227
+ this.init(authOptions);
228
+ AuthEvents.emit(AuthEventNames.isGuestAuthenticated);
229
+ }
230
+ logout() {
231
+ console.debug("logout guest");
232
+ if (!this.pluginState)
233
+ return;
234
+ LocalStorageUtils.removeItem(this.pluginState.guestKey);
235
+ this.pluginState.guestId = "";
236
+ this.pluginState.guestRoles = [];
237
+ window.location.reload();
238
+ }
239
+ }
@@ -1,4 +1,4 @@
1
- import { AxiosInstance } from 'axios';
1
+ import type { AxiosInstance } from "axios";
2
2
  export declare class AxiosAuthInterceptor {
3
3
  static addAuthTokenInterceptor(axiosInstance: AxiosInstance): number;
4
4
  static addAuthErrorInterceptor(axiosInstance: AxiosInstance): number;
@@ -1,61 +1,31 @@
1
- import { __awaiter, __generator } from "tslib";
2
- import { AuthEvents, AuthEventNames } from './AuthEvents';
3
- import Auth from './index';
4
- var AxiosAuthInterceptor = /** @class */ (function () {
5
- function AxiosAuthInterceptor() {
1
+ import { AuthEvents, AuthEventNames } from "./AuthEvents";
2
+ import Auth from "./index";
3
+ export class AxiosAuthInterceptor {
4
+ static addAuthTokenInterceptor(axiosInstance) {
5
+ return axiosInstance.interceptors.request.use(async (requestConfig) => {
6
+ const token = await Auth.getToken();
7
+ if (token) {
8
+ if (Auth.isGuest) {
9
+ requestConfig.headers["guestid"] = token;
10
+ }
11
+ else {
12
+ requestConfig.headers["Authorization"] = `Bearer ${token}`;
13
+ }
14
+ }
15
+ return requestConfig;
16
+ }, null);
6
17
  }
7
- Object.defineProperty(AxiosAuthInterceptor, "addAuthTokenInterceptor", {
8
- enumerable: false,
9
- configurable: true,
10
- writable: true,
11
- value: function (axiosInstance) {
12
- var _this = this;
13
- var onRequest = function (requestConfig) { return __awaiter(_this, void 0, void 0, function () {
14
- var token;
15
- return __generator(this, function (_a) {
16
- switch (_a.label) {
17
- case 0: return [4 /*yield*/, Auth.getToken()];
18
- case 1:
19
- token = _a.sent();
20
- if (token) {
21
- if (Auth.isGuest) {
22
- requestConfig.headers['guestid'] = token;
23
- }
24
- else {
25
- requestConfig.headers['Authorization'] = "Bearer ".concat(token);
26
- }
27
- }
28
- return [2 /*return*/, requestConfig];
29
- }
30
- });
31
- }); };
32
- return axiosInstance.interceptors.request.use(onRequest, null);
33
- }
34
- });
35
- Object.defineProperty(AxiosAuthInterceptor, "addAuthErrorInterceptor", {
36
- enumerable: false,
37
- configurable: true,
38
- writable: true,
39
- value: function (axiosInstance) {
40
- var _this = this;
41
- var onError = function (error) { return __awaiter(_this, void 0, void 0, function () {
42
- var _a, _b, _c, _d;
43
- return __generator(this, function (_e) {
44
- if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
45
- console.warn('axios api request requires authentication', (_b = error.config) === null || _b === void 0 ? void 0 : _b.url, error.message);
46
- AuthEvents.$emit(AuthEventNames.loginRequired);
47
- }
48
- else if (((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === 403) {
49
- console.warn('axios api request requires permission', (_d = error.config) === null || _d === void 0 ? void 0 : _d.url, error.message);
50
- AuthEvents.$emit(AuthEventNames.permissionDenied);
51
- }
52
- throw error;
53
- });
54
- }); };
55
- return axiosInstance.interceptors.response.use(null, onError);
56
- }
57
- });
58
- return AxiosAuthInterceptor;
59
- }());
60
- export { AxiosAuthInterceptor };
61
- //# sourceMappingURL=AxiosAuthInterceptor.js.map
18
+ static addAuthErrorInterceptor(axiosInstance) {
19
+ return axiosInstance.interceptors.response.use(null, (error) => {
20
+ if (error.response?.status === 401) {
21
+ console.warn("axios api request requires authentication", error.config?.url, error.message);
22
+ AuthEvents.emit(AuthEventNames.loginRequired);
23
+ }
24
+ else if (error.response?.status === 403) {
25
+ console.warn("axios api request requires permission", error.config?.url, error.message);
26
+ AuthEvents.emit(AuthEventNames.permissionDenied);
27
+ }
28
+ throw error;
29
+ });
30
+ }
31
+ }
@@ -2,7 +2,6 @@ declare class LocalStorageUtils {
2
2
  setItem(key: string, value: string): void;
3
3
  setItems(key: string, values: string[]): void;
4
4
  getItem(key: string): string;
5
- getItems(key: string): string[];
6
5
  removeItem(key: string): void;
7
6
  }
8
7
  declare const _default: LocalStorageUtils;
@@ -1,55 +1,22 @@
1
- import _ from 'lodash';
2
- var LocalStorageUtils = /** @class */ (function () {
3
- function LocalStorageUtils() {
4
- }
5
- Object.defineProperty(LocalStorageUtils.prototype, "setItem", {
6
- enumerable: false,
7
- configurable: true,
8
- writable: true,
9
- value: function (key, value) {
10
- if (value) {
11
- localStorage.setItem(key, value);
12
- }
13
- else {
14
- localStorage.removeItem(key);
15
- }
16
- }
17
- });
18
- Object.defineProperty(LocalStorageUtils.prototype, "setItems", {
19
- enumerable: false,
20
- configurable: true,
21
- writable: true,
22
- value: function (key, values) {
23
- this.setItem(key, _.join(values, ','));
24
- }
25
- });
26
- Object.defineProperty(LocalStorageUtils.prototype, "getItem", {
27
- enumerable: false,
28
- configurable: true,
29
- writable: true,
30
- value: function (key) {
31
- var text = localStorage.getItem(key);
32
- return typeof text === 'undefined' ? null : text;
33
- }
34
- });
35
- Object.defineProperty(LocalStorageUtils.prototype, "getItems", {
36
- enumerable: false,
37
- configurable: true,
38
- writable: true,
39
- value: function (key) {
40
- var text = this.getItem(key);
41
- return text !== null ? _.split(text, ',') : null;
1
+ import _ from "lodash";
2
+ class LocalStorageUtils {
3
+ setItem(key, value) {
4
+ if (value) {
5
+ localStorage.setItem(key, value);
42
6
  }
43
- });
44
- Object.defineProperty(LocalStorageUtils.prototype, "removeItem", {
45
- enumerable: false,
46
- configurable: true,
47
- writable: true,
48
- value: function (key) {
7
+ else {
49
8
  localStorage.removeItem(key);
50
9
  }
51
- });
52
- return LocalStorageUtils;
53
- }());
10
+ }
11
+ setItems(key, values) {
12
+ this.setItem(key, _.join(values, ","));
13
+ }
14
+ getItem(key) {
15
+ const text = localStorage.getItem(key) ?? "";
16
+ return text === "undefined" ? "" : text;
17
+ }
18
+ removeItem(key) {
19
+ localStorage.removeItem(key);
20
+ }
21
+ }
54
22
  export default new LocalStorageUtils();
55
- //# sourceMappingURL=LocalStorageUtils.js.map
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { AuthPlugin } from './AuthPlugin';
2
- export * from './AuthEvents';
3
- export * from './AuthOptions';
4
- export * from './AxiosAuthInterceptor';
1
+ import { AuthPlugin } from "./AuthPlugin";
2
+ export * from "./AuthEvents";
3
+ export * from "./AuthOptions";
4
+ export * from "./AxiosAuthInterceptor";
5
5
  declare const _default: AuthPlugin;
6
6
  export default _default;
package/lib/index.js CHANGED
@@ -1,6 +1,5 @@
1
- import { AuthPlugin } from './AuthPlugin';
2
- export * from './AuthEvents';
3
- export * from './AuthOptions';
4
- export * from './AxiosAuthInterceptor';
1
+ import { AuthPlugin } from "./AuthPlugin";
2
+ export * from "./AuthEvents";
3
+ export * from "./AuthOptions";
4
+ export * from "./AxiosAuthInterceptor";
5
5
  export default new AuthPlugin();
6
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samhammer/authentication-vue",
3
- "version": "1.3.2",
3
+ "version": "2.0.0",
4
4
  "description": "Keycloak authentication for VueJS projects",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -24,23 +24,24 @@
24
24
  "postversion": "git push && git push --tags"
25
25
  },
26
26
  "devDependencies": {
27
- "@types/lodash": "^4.14.178",
28
- "@types/uuid": "^8.3.3",
29
- "@typescript-eslint/eslint-plugin": "^5.9.0",
30
- "@typescript-eslint/parser": "^5.9.0",
31
- "eslint": "^8.6.0",
32
- "eslint-config-prettier": "^8.3.0",
33
- "eslint-plugin-import": "^2.25.4",
34
- "eslint-plugin-prettier": "^4.0.0",
35
- "prettier": "^2.5.1",
36
- "tslib": "^2.3.1",
37
- "typescript": "^4.5.4"
27
+ "@rushstack/eslint-patch": "^1.2.0",
28
+ "@types/lodash": "^4.14.191",
29
+ "@types/node": "^18.15.1",
30
+ "@types/uuid": "^9.0.1",
31
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
32
+ "@typescript-eslint/parser": "^5.54.1",
33
+ "eslint": "^8.36.0",
34
+ "eslint-config-prettier": "^8.7.0",
35
+ "eslint-plugin-import": "^2.27.5",
36
+ "eslint-plugin-prettier": "^4.2.1",
37
+ "prettier": "^2.7.1",
38
+ "typescript": "^4.7.4"
38
39
  },
39
40
  "dependencies": {
40
- "axios": "0.27.2",
41
- "keycloak-js": "^19.0.1",
41
+ "axios": "1.3.4",
42
+ "emittery": "^1.0.1",
43
+ "keycloak-js": "^20.0.3",
42
44
  "lodash": "^4.17.21",
43
- "uuid": "^8.3.2",
44
- "vue": "^2.6.14"
45
+ "uuid": "^9.0.0"
45
46
  }
46
47
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthEvents.js","sourceRoot":"","sources":["../src/AuthEvents.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACtB,mEAAiD,CAAA;IACjD,+DAA6C,CAAA;IAC7C,iDAA+B,CAAA;IAC/B,uDAAqC,CAAA;AACzC,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED,MAAM,CAAC,IAAM,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthOptions.js","sourceRoot":"","sources":["../src/AuthOptions.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthPlugin.js","sourceRoot":"","sources":["../src/AuthPlugin.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE1D;IAAA;QAAA,iBAmDC;QAlDG;;;;;WAAiC;QACjC;;;;mBAAmC,IAAI,cAAc,EAAE;WAAC;QACxD;;;;mBAA6B,IAAI,WAAW,EAAE;WAAC;QAqB/C;;;;mBAAkE,IAAI,CAAC,UAAO,WAAW;;;;;4BACrF,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;4BACA,KAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;oCAAjC,wBAAiC;4BAAK,qBAAM,IAAI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