@adminforth/two-factors-auth 2.10.0 → 2.10.2
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/build.log +2 -2
- package/custom/TwoFAModal.vue +4 -4
- package/dist/custom/TwoFAModal.vue +4 -4
- package/dist/index.js +6 -5
- package/index.ts +6 -5
- package/package.json +1 -1
package/build.log
CHANGED
|
@@ -15,5 +15,5 @@ custom/package.json
|
|
|
15
15
|
custom/tsconfig.json
|
|
16
16
|
custom/utils.js
|
|
17
17
|
|
|
18
|
-
sent 273,
|
|
19
|
-
total size is 272,
|
|
18
|
+
sent 273,585 bytes received 210 bytes 547,590.00 bytes/sec
|
|
19
|
+
total size is 272,758 speedup is 1.00
|
package/custom/TwoFAModal.vue
CHANGED
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
declare global {
|
|
86
86
|
interface Window {
|
|
87
87
|
adminforthTwoFaModal: {
|
|
88
|
-
get2FaConfirmationResult: (
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
get2FaConfirmationResult: (
|
|
89
|
+
title?: string,
|
|
90
|
+
verifyingCallback?: (confirmationResult: string) => Promise<boolean>
|
|
91
91
|
) => Promise<any>;
|
|
92
92
|
};
|
|
93
93
|
}
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
window.adminforthTwoFaModal = {
|
|
130
|
-
get2FaConfirmationResult: (verifyingCallback?: (confirmationResult: string) => Promise<boolean
|
|
130
|
+
get2FaConfirmationResult: (title?: string, verifyingCallback?: (confirmationResult: string) => Promise<boolean>) =>
|
|
131
131
|
new Promise(async (resolve, reject) => {
|
|
132
132
|
if (modelShow.value) throw new Error('Modal is already open');
|
|
133
133
|
const skipAllowModal = await checkIfSkipAllowModal();
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
declare global {
|
|
86
86
|
interface Window {
|
|
87
87
|
adminforthTwoFaModal: {
|
|
88
|
-
get2FaConfirmationResult: (
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
get2FaConfirmationResult: (
|
|
89
|
+
title?: string,
|
|
90
|
+
verifyingCallback?: (confirmationResult: string) => Promise<boolean>
|
|
91
91
|
) => Promise<any>;
|
|
92
92
|
};
|
|
93
93
|
}
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
window.adminforthTwoFaModal = {
|
|
130
|
-
get2FaConfirmationResult: (verifyingCallback?: (confirmationResult: string) => Promise<boolean
|
|
130
|
+
get2FaConfirmationResult: (title?: string, verifyingCallback?: (confirmationResult: string) => Promise<boolean>) =>
|
|
131
131
|
new Promise(async (resolve, reject) => {
|
|
132
132
|
if (modelShow.value) throw new Error('Modal is already open');
|
|
133
133
|
const skipAllowModal = await checkIfSkipAllowModal();
|
package/dist/index.js
CHANGED
|
@@ -46,17 +46,18 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
46
46
|
return { skipAllowed: false };
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
generateHashForStepUpMfaGraceCookie(headers) {
|
|
49
|
+
generateHashForStepUpMfaGraceCookie(headers, cookies) {
|
|
50
50
|
const ip = this.adminforth.auth.getClientIp(headers);
|
|
51
51
|
const userAgent = headers['user-agent'] || '';
|
|
52
52
|
const acceptLanguage = headers['accept-language'] || '';
|
|
53
|
-
|
|
53
|
+
const session_cookie = this.adminforth.auth.getCustomCookie({ cookies: cookies, name: "jwt" });
|
|
54
|
+
if (!ip || !userAgent || !acceptLanguage || !session_cookie) {
|
|
54
55
|
console.error("❗️❗️❗️ Cannot set step-up MFA grace cookie: missing required request headers to identify client ❗️❗️❗️");
|
|
55
56
|
return null;
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
59
|
const hmac = crypto.createHmac('sha256', process.env.ADMINFORTH_SECRET)
|
|
59
|
-
.update(`${acceptLanguage}_${userAgent}_${ip}`)
|
|
60
|
+
.update(`${acceptLanguage}_${userAgent}_${ip}_${session_cookie}`)
|
|
60
61
|
.digest('hex');
|
|
61
62
|
return hmac;
|
|
62
63
|
}
|
|
@@ -64,7 +65,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
64
65
|
issueTempSkip2FAGraceJWT(opts) {
|
|
65
66
|
if (opts.response) {
|
|
66
67
|
if (opts.extra.headers) {
|
|
67
|
-
const hash = this.generateHashForStepUpMfaGraceCookie(opts.extra.headers);
|
|
68
|
+
const hash = this.generateHashForStepUpMfaGraceCookie(opts.extra.headers, opts.cookies);
|
|
68
69
|
if (!hash) {
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
@@ -80,7 +81,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
80
81
|
}
|
|
81
82
|
isTempSkip2FAGraceValid(headers_1, cookies_1) {
|
|
82
83
|
return __awaiter(this, arguments, void 0, function* (headers, cookies, checkIfJWTAboutToExpire = false) {
|
|
83
|
-
const hash = this.generateHashForStepUpMfaGraceCookie(headers);
|
|
84
|
+
const hash = this.generateHashForStepUpMfaGraceCookie(headers, cookies);
|
|
84
85
|
if (!hash) {
|
|
85
86
|
return false;
|
|
86
87
|
}
|
package/index.ts
CHANGED
|
@@ -55,16 +55,17 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
55
55
|
return { skipAllowed: false };
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
private generateHashForStepUpMfaGraceCookie(headers): string {
|
|
58
|
+
private generateHashForStepUpMfaGraceCookie(headers, cookies): string {
|
|
59
59
|
const ip = this.adminforth.auth.getClientIp(headers);
|
|
60
60
|
const userAgent = headers['user-agent'] || '';
|
|
61
61
|
const acceptLanguage = headers['accept-language'] || '';
|
|
62
|
-
|
|
62
|
+
const session_cookie = this.adminforth.auth.getCustomCookie({cookies: cookies, name: "jwt"});
|
|
63
|
+
if (!ip || !userAgent || !acceptLanguage || !session_cookie) {
|
|
63
64
|
console.error("❗️❗️❗️ Cannot set step-up MFA grace cookie: missing required request headers to identify client ❗️❗️❗️");
|
|
64
65
|
return null;
|
|
65
66
|
} else {
|
|
66
67
|
const hmac = crypto.createHmac('sha256', process.env.ADMINFORTH_SECRET)
|
|
67
|
-
.update(`${acceptLanguage}_${userAgent}_${ip}`)
|
|
68
|
+
.update(`${acceptLanguage}_${userAgent}_${ip}_${session_cookie}`)
|
|
68
69
|
.digest('hex');
|
|
69
70
|
return hmac;
|
|
70
71
|
}
|
|
@@ -73,7 +74,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
73
74
|
private issueTempSkip2FAGraceJWT(opts): void {
|
|
74
75
|
if (opts.response) {
|
|
75
76
|
if (opts.extra.headers) {
|
|
76
|
-
const hash = this.generateHashForStepUpMfaGraceCookie(opts.extra.headers);
|
|
77
|
+
const hash = this.generateHashForStepUpMfaGraceCookie(opts.extra.headers, opts.cookies);
|
|
77
78
|
if (!hash) {
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
@@ -88,7 +89,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
private async isTempSkip2FAGraceValid(headers, cookies, checkIfJWTAboutToExpire: boolean = false): Promise<boolean> {
|
|
91
|
-
const hash = this.generateHashForStepUpMfaGraceCookie(headers);
|
|
92
|
+
const hash = this.generateHashForStepUpMfaGraceCookie(headers, cookies);
|
|
92
93
|
if (!hash) {
|
|
93
94
|
return false;
|
|
94
95
|
}
|