@alfabit/keycloak 0.0.12 → 0.0.14
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/package.json
CHANGED
|
@@ -98,13 +98,6 @@ export const getAuthMethods = () => {
|
|
|
98
98
|
const methods = reactive({
|
|
99
99
|
async loginPopup(idpHint: TIdpHint, redirectUri?: string) {
|
|
100
100
|
redirectUri = redirectUri ?? getUrl();
|
|
101
|
-
|
|
102
|
-
console.log({
|
|
103
|
-
isMobile: isMobile(),
|
|
104
|
-
idpHint,
|
|
105
|
-
redirectUri,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
101
|
if (isMobile()) {
|
|
109
102
|
switch (idpHint) {
|
|
110
103
|
case 'google':
|
|
@@ -176,12 +169,6 @@ export const getAuthMethods = () => {
|
|
|
176
169
|
if (keycloak.value) {
|
|
177
170
|
clearTokens();
|
|
178
171
|
setTimeout(() => {
|
|
179
|
-
console.log('logout', {
|
|
180
|
-
keycloakRedirectUriIsLogout: keycloakRedirectUriIsLogout.value,
|
|
181
|
-
dontChangeRedirectUri: dontChangeRedirectUri.value,
|
|
182
|
-
redirectUri: redirectUri ?? getUrl(),
|
|
183
|
-
});
|
|
184
|
-
|
|
185
172
|
keycloak.value &&
|
|
186
173
|
keycloak.value.logout({
|
|
187
174
|
redirectUri: redirectUri ?? getUrl(),
|
|
@@ -320,7 +307,7 @@ const isPopup = () => {
|
|
|
320
307
|
);
|
|
321
308
|
}
|
|
322
309
|
} catch (err) {
|
|
323
|
-
console.
|
|
310
|
+
console.warn('Error in login-popup-redirect.html:', err);
|
|
324
311
|
}
|
|
325
312
|
};
|
|
326
313
|
|
|
@@ -335,7 +322,7 @@ export async function initKeycloak() {
|
|
|
335
322
|
if (!OPENID_CLIENT_ID) throw new Error('Не задана переменная keycloak: clientId');
|
|
336
323
|
|
|
337
324
|
// console.log({
|
|
338
|
-
//
|
|
325
|
+
// OPENID_URL,
|
|
339
326
|
// OPENID_REALM,
|
|
340
327
|
// OPENID_CLIENT_ID,
|
|
341
328
|
|
|
@@ -353,10 +340,6 @@ export async function initKeycloak() {
|
|
|
353
340
|
clientId: OPENID_CLIENT_ID,
|
|
354
341
|
});
|
|
355
342
|
|
|
356
|
-
console.log({
|
|
357
|
-
keycloak: keycloak.value,
|
|
358
|
-
});
|
|
359
|
-
|
|
360
343
|
const isNeedAuth = !!getToken() && !isRtExp();
|
|
361
344
|
|
|
362
345
|
// window.opener - если находимся в popup (но не в passport), то 100% уже авторизованы и можно поставить login-required
|
|
@@ -385,19 +368,9 @@ export async function initKeycloak() {
|
|
|
385
368
|
if (idToken) initOptions.idToken = idToken;
|
|
386
369
|
}
|
|
387
370
|
|
|
388
|
-
console.log({
|
|
389
|
-
initOptions,
|
|
390
|
-
});
|
|
391
|
-
|
|
392
371
|
try {
|
|
393
|
-
console.log('before keycloak init');
|
|
394
|
-
|
|
395
372
|
const res = await keycloak.value.init(initOptions);
|
|
396
373
|
|
|
397
|
-
console.log('after keycloak init', {
|
|
398
|
-
res,
|
|
399
|
-
});
|
|
400
|
-
|
|
401
374
|
setTokens();
|
|
402
375
|
|
|
403
376
|
if (res) {
|
|
@@ -427,7 +400,7 @@ export async function initKeycloak() {
|
|
|
427
400
|
}
|
|
428
401
|
return isAuth.value;
|
|
429
402
|
} catch (error) {
|
|
430
|
-
console.
|
|
403
|
+
console.warn('Ошибка Keycloak:', error);
|
|
431
404
|
isAuth.value = false;
|
|
432
405
|
return false;
|
|
433
406
|
} finally {
|
|
@@ -457,8 +430,6 @@ let _keycloakInit: IUseKeycloak | null = null;
|
|
|
457
430
|
export const keycloakInit = (dontChangeRedirectUri?: Ref<boolean>, keycloakRedirectUriIsLogout?: Ref<string | undefined>): IUseKeycloak => {
|
|
458
431
|
if (_keycloakInit) return _keycloakInit;
|
|
459
432
|
|
|
460
|
-
console.log('>>>>> Lazy keycloakInit called');
|
|
461
|
-
|
|
462
433
|
dontChangeRedirectUri ||= inject('dontChangeRedirectUri', ref(false));
|
|
463
434
|
keycloakRedirectUriIsLogout ||= inject('keycloakRedirectUriIsLogout', ref(undefined));
|
|
464
435
|
|
|
@@ -475,8 +446,5 @@ export const keycloakInit = (dontChangeRedirectUri?: Ref<boolean>, keycloakRedir
|
|
|
475
446
|
isAtExp,
|
|
476
447
|
isRtExp,
|
|
477
448
|
};
|
|
478
|
-
|
|
479
|
-
console.log('@alfabit/keycloak fn keycloakInit', {_keycloakInit});
|
|
480
|
-
|
|
481
449
|
return _keycloakInit;
|
|
482
450
|
};
|
package/src/plugins/keycloak.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { ref } from 'vue';
|
|
|
2
2
|
import { createKeycloakInit, getAuthMethods, keycloakInit } from '../composables';
|
|
3
3
|
|
|
4
4
|
export const useKeycloak = () => {
|
|
5
|
-
console.trace('Trace: useKeycloak');
|
|
6
|
-
console.log('@alfabit/keycloak fn useKeycloak');
|
|
7
5
|
const keycloak = keycloakInit(ref(false), ref(undefined));
|
|
8
6
|
const auth = getAuthMethods();
|
|
9
7
|
return {
|
|
@@ -13,13 +11,11 @@ export const useKeycloak = () => {
|
|
|
13
11
|
};
|
|
14
12
|
|
|
15
13
|
export const createKeycloak = () => {
|
|
16
|
-
console.log('@alfabit/keycloak fn createKeycloak');
|
|
17
14
|
createKeycloakInit();
|
|
18
15
|
};
|
|
19
16
|
|
|
20
17
|
export const keycloakPlugin = {
|
|
21
18
|
install() {
|
|
22
|
-
console.log('@alfabit/keycloak plugin install');
|
|
23
19
|
createKeycloak();
|
|
24
20
|
//app.config.globalProperties.$keycloak = useKeycloak();
|
|
25
21
|
},
|