@adminforth/two-factors-auth 6.0.0 → 7.0.1
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/LoginWithPasskeyButton.vue +3 -2
- package/custom/TwoFAModal.vue +2 -0
- package/custom/TwoFaCard.vue +28 -36
- package/custom/TwoFactorsSetup.vue +1 -1
- package/dist/custom/LoginWithPasskeyButton.vue +3 -2
- package/dist/custom/TwoFAModal.vue +2 -0
- package/dist/custom/TwoFaCard.vue +28 -36
- package/dist/custom/TwoFactorsSetup.vue +1 -1
- package/dist/index.js +3 -3
- package/dist/repositories/passkeyRepository.js +1 -1
- package/dist/services/cookieService.js +3 -3
- package/index.ts +4 -4
- package/package.json +3 -3
- package/repositories/passkeyRepository.ts +1 -1
- package/services/cookieService.ts +3 -3
package/build.log
CHANGED
|
@@ -21,5 +21,5 @@ custom/tsconfig.json
|
|
|
21
21
|
custom/use2faApi.ts
|
|
22
22
|
custom/utils.js
|
|
23
23
|
|
|
24
|
-
sent
|
|
25
|
-
total size is
|
|
24
|
+
sent 300,012 bytes received 324 bytes 600,672.00 bytes/sec
|
|
25
|
+
total size is 298,778 speedup is 0.99
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
|
|
3
|
+
<!-- right after the OAuth buttons it joins them with their 8px gap instead of the 16px between login page injections -->
|
|
3
4
|
<Button
|
|
4
5
|
variant="secondary"
|
|
5
|
-
class="af-login-with-passkey-btn w-full gap-2"
|
|
6
|
+
class="af-login-with-passkey-btn w-full gap-2 [.af-oauth-login+&]:!mt-2"
|
|
6
7
|
@click="handleLoginWithPasskey"
|
|
7
8
|
>
|
|
8
|
-
<IconFingerprint class="w-
|
|
9
|
+
<IconFingerprint class="w-4 h-4 text-lightPrimary dark:text-darkPrimary" />
|
|
9
10
|
{{ $t('Continue with Passkey') }}
|
|
10
11
|
</Button>
|
|
11
12
|
|
package/custom/TwoFAModal.vue
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="af-two-factors-modal fixed inset-0 z-[9999] flex items-center justify-center bg-lightScrim dark:bg-darkScrim top-0 bottom-0 left-0 right-0 px-4"
|
|
3
3
|
v-if="modelShow && (isLoading === false)">
|
|
4
|
+
<!-- the card floats over the page here, so it takes the shadow of floating layers -->
|
|
4
5
|
<TwoFaCard
|
|
6
|
+
class="shadow-popover dark:shadow-darkPopover"
|
|
5
7
|
:class="`af-two-factor-modal-${modalMode}`"
|
|
6
8
|
:title="dialogTitle"
|
|
7
9
|
:subtitle="subtitles[modalMode]"
|
package/custom/TwoFaCard.vue
CHANGED
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
</
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
<slot />
|
|
27
|
-
<p v-if="error" role="alert" class="af-2fa-code-error -mt-2.5 flex items-center gap-1.5 text-sm text-lightDanger dark:text-darkDanger">
|
|
28
|
-
<IconCircleAlert class="w-4 h-4 shrink-0" />
|
|
29
|
-
{{ error }}
|
|
30
|
-
</p>
|
|
31
|
-
</div>
|
|
32
|
-
|
|
33
|
-
<div v-if="$slots.footer" class="af-2fa-footer flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-lightDialogBreakLine bg-lightFormHeading py-3 pl-6 pr-5 dark:border-darkDialogBreakLine dark:bg-darkFormHeading">
|
|
2
|
+
<DialogPanel
|
|
3
|
+
class="af-2fa-card"
|
|
4
|
+
:title="title"
|
|
5
|
+
:subtitle="subtitle"
|
|
6
|
+
:error="error"
|
|
7
|
+
:closable="closable"
|
|
8
|
+
:classes="{
|
|
9
|
+
header: 'af-2fa-header',
|
|
10
|
+
icon: 'af-2fa-icon-wrap',
|
|
11
|
+
titleWrap: 'af-2fa-title-wrap',
|
|
12
|
+
title: 'af-2fa-title',
|
|
13
|
+
subtitle: 'af-2fa-subtitle',
|
|
14
|
+
close: 'af-2fa-close-btn',
|
|
15
|
+
body: 'af-2fa-body',
|
|
16
|
+
error: 'af-2fa-code-error',
|
|
17
|
+
footer: 'af-2fa-footer',
|
|
18
|
+
}"
|
|
19
|
+
@close="emit('close')"
|
|
20
|
+
>
|
|
21
|
+
<template #icon>
|
|
22
|
+
<IconShieldCheck class="af-2fa-shield-icon" />
|
|
23
|
+
</template>
|
|
24
|
+
<slot />
|
|
25
|
+
<template v-if="$slots.footer" #footer>
|
|
34
26
|
<slot name="footer" />
|
|
35
|
-
</
|
|
36
|
-
</
|
|
27
|
+
</template>
|
|
28
|
+
</DialogPanel>
|
|
37
29
|
</template>
|
|
38
30
|
|
|
39
31
|
<script setup lang="ts">
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
32
|
+
import { IconShieldCheck } from '@iconify-prerendered/vue-lucide';
|
|
33
|
+
import { DialogPanel } from '@/afcl';
|
|
42
34
|
|
|
43
35
|
defineProps<{
|
|
44
36
|
title: string;
|
|
@@ -146,7 +146,7 @@ function onCopyClick(){
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
onMounted(async () => {
|
|
149
|
-
coreStore.
|
|
149
|
+
coreStore.fetchConfig({ redirectToLoginIfNotLoggedIn: false })
|
|
150
150
|
const resp = await callAdminForthApi({
|
|
151
151
|
path: '/plugin/twofa/initSetup',
|
|
152
152
|
method: 'POST',});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
|
|
3
|
+
<!-- right after the OAuth buttons it joins them with their 8px gap instead of the 16px between login page injections -->
|
|
3
4
|
<Button
|
|
4
5
|
variant="secondary"
|
|
5
|
-
class="af-login-with-passkey-btn w-full gap-2"
|
|
6
|
+
class="af-login-with-passkey-btn w-full gap-2 [.af-oauth-login+&]:!mt-2"
|
|
6
7
|
@click="handleLoginWithPasskey"
|
|
7
8
|
>
|
|
8
|
-
<IconFingerprint class="w-
|
|
9
|
+
<IconFingerprint class="w-4 h-4 text-lightPrimary dark:text-darkPrimary" />
|
|
9
10
|
{{ $t('Continue with Passkey') }}
|
|
10
11
|
</Button>
|
|
11
12
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="af-two-factors-modal fixed inset-0 z-[9999] flex items-center justify-center bg-lightScrim dark:bg-darkScrim top-0 bottom-0 left-0 right-0 px-4"
|
|
3
3
|
v-if="modelShow && (isLoading === false)">
|
|
4
|
+
<!-- the card floats over the page here, so it takes the shadow of floating layers -->
|
|
4
5
|
<TwoFaCard
|
|
6
|
+
class="shadow-popover dark:shadow-darkPopover"
|
|
5
7
|
:class="`af-two-factor-modal-${modalMode}`"
|
|
6
8
|
:title="dialogTitle"
|
|
7
9
|
:subtitle="subtitles[modalMode]"
|
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
</
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
<slot />
|
|
27
|
-
<p v-if="error" role="alert" class="af-2fa-code-error -mt-2.5 flex items-center gap-1.5 text-sm text-lightDanger dark:text-darkDanger">
|
|
28
|
-
<IconCircleAlert class="w-4 h-4 shrink-0" />
|
|
29
|
-
{{ error }}
|
|
30
|
-
</p>
|
|
31
|
-
</div>
|
|
32
|
-
|
|
33
|
-
<div v-if="$slots.footer" class="af-2fa-footer flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-lightDialogBreakLine bg-lightFormHeading py-3 pl-6 pr-5 dark:border-darkDialogBreakLine dark:bg-darkFormHeading">
|
|
2
|
+
<DialogPanel
|
|
3
|
+
class="af-2fa-card"
|
|
4
|
+
:title="title"
|
|
5
|
+
:subtitle="subtitle"
|
|
6
|
+
:error="error"
|
|
7
|
+
:closable="closable"
|
|
8
|
+
:classes="{
|
|
9
|
+
header: 'af-2fa-header',
|
|
10
|
+
icon: 'af-2fa-icon-wrap',
|
|
11
|
+
titleWrap: 'af-2fa-title-wrap',
|
|
12
|
+
title: 'af-2fa-title',
|
|
13
|
+
subtitle: 'af-2fa-subtitle',
|
|
14
|
+
close: 'af-2fa-close-btn',
|
|
15
|
+
body: 'af-2fa-body',
|
|
16
|
+
error: 'af-2fa-code-error',
|
|
17
|
+
footer: 'af-2fa-footer',
|
|
18
|
+
}"
|
|
19
|
+
@close="emit('close')"
|
|
20
|
+
>
|
|
21
|
+
<template #icon>
|
|
22
|
+
<IconShieldCheck class="af-2fa-shield-icon" />
|
|
23
|
+
</template>
|
|
24
|
+
<slot />
|
|
25
|
+
<template v-if="$slots.footer" #footer>
|
|
34
26
|
<slot name="footer" />
|
|
35
|
-
</
|
|
36
|
-
</
|
|
27
|
+
</template>
|
|
28
|
+
</DialogPanel>
|
|
37
29
|
</template>
|
|
38
30
|
|
|
39
31
|
<script setup lang="ts">
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
32
|
+
import { IconShieldCheck } from '@iconify-prerendered/vue-lucide';
|
|
33
|
+
import { DialogPanel } from '@/afcl';
|
|
42
34
|
|
|
43
35
|
defineProps<{
|
|
44
36
|
title: string;
|
|
@@ -146,7 +146,7 @@ function onCopyClick(){
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
onMounted(async () => {
|
|
149
|
-
coreStore.
|
|
149
|
+
coreStore.fetchConfig({ redirectToLoginIfNotLoggedIn: false })
|
|
150
150
|
const resp = await callAdminForthApi({
|
|
151
151
|
path: '/plugin/twofa/initSetup',
|
|
152
152
|
method: 'POST',});
|
package/dist/index.js
CHANGED
|
@@ -278,7 +278,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
278
278
|
}
|
|
279
279
|
const beforeLoginConfirmation = this.adminforth.config.auth.beforeLoginConfirmation;
|
|
280
280
|
const beforeLoginConfirmationArray = Array.isArray(beforeLoginConfirmation) ? beforeLoginConfirmation : [beforeLoginConfirmation];
|
|
281
|
-
beforeLoginConfirmationArray.push((_a) => __awaiter(this, [_a], void 0, function* ({ adminUser,
|
|
281
|
+
beforeLoginConfirmationArray.push((_a) => __awaiter(this, [_a], void 0, function* ({ adminUser, adminforth, extra, sessionDuration }) {
|
|
282
282
|
var _b;
|
|
283
283
|
if (((_b = extra === null || extra === void 0 ? void 0 : extra.meta) === null || _b === void 0 ? void 0 : _b.loginAllowedByPasskeyDirectSignIn) === true) {
|
|
284
284
|
return { body: { loginAllowed: true }, ok: true };
|
|
@@ -299,7 +299,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
299
299
|
const userCanSkipSetup = this.options.usersFilterToAllowSkipSetup ? this.options.usersFilterToAllowSkipSetup(adminUser) : false;
|
|
300
300
|
if (!secret) {
|
|
301
301
|
newSecret = this.totpService.generateSecret(issuerName, userName);
|
|
302
|
-
this.cookieService.setTotpTemporary(response, { userName, newSecret, issuer: issuerName, pk: userPk, userCanSkipSetup, sessionDuration });
|
|
302
|
+
this.cookieService.setTotpTemporary(extra.response, { userName, newSecret, issuer: issuerName, pk: userPk, userCanSkipSetup, sessionDuration });
|
|
303
303
|
return {
|
|
304
304
|
body: {
|
|
305
305
|
loginAllowed: false,
|
|
@@ -309,7 +309,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
311
|
else {
|
|
312
|
-
this.cookieService.setTotpTemporary(response, { userName, issuer: issuerName, pk: userPk, userCanSkipSetup, sessionDuration });
|
|
312
|
+
this.cookieService.setTotpTemporary(extra.response, { userName, issuer: issuerName, pk: userPk, userCanSkipSetup, sessionDuration });
|
|
313
313
|
return {
|
|
314
314
|
body: {
|
|
315
315
|
loginAllowed: false,
|
|
@@ -41,7 +41,7 @@ export class CookieService {
|
|
|
41
41
|
const value = this.adminforth.auth.issueJWT(payload, 'temp2FA', period);
|
|
42
42
|
this.adminforth.auth.setCustomCookie({
|
|
43
43
|
response,
|
|
44
|
-
payload: { name: TOTP_TEMP_COOKIE, value,
|
|
44
|
+
payload: { name: TOTP_TEMP_COOKIE, value, expirySeconds: convertPeriodToSeconds(period), httpOnly: true },
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
removeTotpTemporary(response) {
|
|
@@ -63,7 +63,7 @@ export class CookieService {
|
|
|
63
63
|
const value = this.adminforth.auth.issueJWT({ challenge }, 'tempLoginPasskeyChallenge', ((_a = this.options.passkeys) === null || _a === void 0 ? void 0 : _a.challengeValidityPeriod) || '1m');
|
|
64
64
|
this.adminforth.auth.setCustomCookie({
|
|
65
65
|
response,
|
|
66
|
-
payload: { name: PASSKEY_LOGIN_TEMP_COOKIE, value,
|
|
66
|
+
payload: { name: PASSKEY_LOGIN_TEMP_COOKIE, value, expirySeconds: 10 * 60, httpOnly: true },
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
getRegisterPasskeyTemporary(cookies) {
|
|
@@ -82,7 +82,7 @@ export class CookieService {
|
|
|
82
82
|
const value = this.adminforth.auth.issueJWT(payload, 'registerTempPasskeyChallenge', ((_a = this.options.passkeys) === null || _a === void 0 ? void 0 : _a.challengeValidityPeriod) || '1m');
|
|
83
83
|
this.adminforth.auth.setCustomCookie({
|
|
84
84
|
response,
|
|
85
|
-
payload: { name: REGISTER_PASSKEY_TEMP_COOKIE, value,
|
|
85
|
+
payload: { name: REGISTER_PASSKEY_TEMP_COOKIE, value, expirySeconds: 10 * 60, httpOnly: true },
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
setMfaGrace(response, hash) {
|
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdminForthPlugin, suggestIfTypo, HttpExtra, RateLimiter } from "adminforth";
|
|
2
2
|
import * as AdminForthRuntime from "adminforth";
|
|
3
|
-
import type { AdminForthResource, AdminUser, IAdminForth, IHttpServer, IAdminForthAuth
|
|
3
|
+
import type { AdminForthResource, AdminUser, IAdminForth, IHttpServer, IAdminForthAuth } from "adminforth";
|
|
4
4
|
import { PluginOptions } from "./types.js"
|
|
5
5
|
import { PasskeyService } from "./services/passkeyService.js";
|
|
6
6
|
import { TotpService } from "./services/totpService.js";
|
|
@@ -331,7 +331,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
331
331
|
const beforeLoginConfirmation = this.adminforth.config.auth.beforeLoginConfirmation;
|
|
332
332
|
const beforeLoginConfirmationArray = Array.isArray(beforeLoginConfirmation) ? beforeLoginConfirmation : [beforeLoginConfirmation];
|
|
333
333
|
beforeLoginConfirmationArray.push(
|
|
334
|
-
async({ adminUser,
|
|
334
|
+
async({ adminUser, adminforth, extra, sessionDuration }: { adminUser: AdminUser, adminforth: IAdminForth, extra?: HttpExtra, sessionDuration?: string} )=> {
|
|
335
335
|
if ( extra?.meta?.loginAllowedByPasskeyDirectSignIn === true) {
|
|
336
336
|
return { body: { loginAllowed: true }, ok: true };
|
|
337
337
|
}
|
|
@@ -353,7 +353,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
353
353
|
|
|
354
354
|
if (!secret){
|
|
355
355
|
newSecret = this.totpService.generateSecret(issuerName, userName);
|
|
356
|
-
this.cookieService.setTotpTemporary(response, {userName, newSecret, issuer:issuerName, pk:userPk, userCanSkipSetup, sessionDuration });
|
|
356
|
+
this.cookieService.setTotpTemporary(extra.response, {userName, newSecret, issuer:issuerName, pk:userPk, userCanSkipSetup, sessionDuration });
|
|
357
357
|
|
|
358
358
|
return {
|
|
359
359
|
body:{
|
|
@@ -364,7 +364,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
} else {
|
|
367
|
-
this.cookieService.setTotpTemporary(response, {userName, issuer:issuerName, pk:userPk, userCanSkipSetup, sessionDuration });
|
|
367
|
+
this.cookieService.setTotpTemporary(extra.response, {userName, issuer:issuerName, pk:userPk, userCanSkipSetup, sessionDuration });
|
|
368
368
|
|
|
369
369
|
return {
|
|
370
370
|
body:{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/two-factors-auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "AdminForth plugin for two factors authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"zod": "^4.3.6"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"adminforth": "^4.
|
|
32
|
+
"adminforth": "^4.6.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^22.10.7",
|
|
36
|
-
"adminforth": "^
|
|
36
|
+
"adminforth": "^4.7.3",
|
|
37
37
|
"semantic-release": "^24.2.1",
|
|
38
38
|
"semantic-release-slack-bot": "^4.0.2",
|
|
39
39
|
"typescript": "^5.7.3"
|
|
@@ -62,7 +62,7 @@ export class CookieService {
|
|
|
62
62
|
const value = this.adminforth.auth.issueJWT(payload, 'temp2FA', period);
|
|
63
63
|
this.adminforth.auth.setCustomCookie({
|
|
64
64
|
response,
|
|
65
|
-
payload: { name: TOTP_TEMP_COOKIE, value,
|
|
65
|
+
payload: { name: TOTP_TEMP_COOKIE, value, expirySeconds: convertPeriodToSeconds(period), httpOnly: true },
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -84,7 +84,7 @@ export class CookieService {
|
|
|
84
84
|
const value = this.adminforth.auth.issueJWT({ challenge }, 'tempLoginPasskeyChallenge', this.options.passkeys?.challengeValidityPeriod || '1m');
|
|
85
85
|
this.adminforth.auth.setCustomCookie({
|
|
86
86
|
response,
|
|
87
|
-
payload: { name: PASSKEY_LOGIN_TEMP_COOKIE, value,
|
|
87
|
+
payload: { name: PASSKEY_LOGIN_TEMP_COOKIE, value, expirySeconds: 10 * 60, httpOnly: true },
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -102,7 +102,7 @@ export class CookieService {
|
|
|
102
102
|
const value = this.adminforth.auth.issueJWT(payload, 'registerTempPasskeyChallenge', this.options.passkeys?.challengeValidityPeriod || '1m');
|
|
103
103
|
this.adminforth.auth.setCustomCookie({
|
|
104
104
|
response,
|
|
105
|
-
payload: { name: REGISTER_PASSKEY_TEMP_COOKIE, value,
|
|
105
|
+
payload: { name: REGISTER_PASSKEY_TEMP_COOKIE, value, expirySeconds: 10 * 60, httpOnly: true },
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
|