Skip to content

Commit 4481811

Browse files
committed
dev-demo: move 2fa plugin config to a separate file
AdminForth/1777/image
1 parent 00ee4ff commit 4481811

2 files changed

Lines changed: 41 additions & 34 deletions

File tree

dev-demo/resources/adminuser.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import AdminForth, { AdminForthDataTypes, logger } from '../../adminforth/index.js';
22
import type { AdminForthResourceInput, AdminForthResource, AdminUser, AdminForthResourceColumn } from '../../adminforth/index.js';
33
import { randomUUID } from 'crypto';
4-
import TwoFactorsAuthPlugin from '../../plugins/adminforth-two-factors-auth/index.js'
54
import ForeignInlineListPlugin from '../../plugins/adminforth-foreign-inline-list/index.js';
65
import UploadPlugin from '../../plugins/adminforth-upload/index.js';
76
import AdminForthStorageAdapterLocalFilesystem from "../../adapters/adminforth-storage-adapter-local/index.js";
@@ -10,6 +9,7 @@ import DashboardPlugin from '../../plugins/adminforth-dashboard/index.js';
109
import UserSoftDelete from '../../plugins/adminforth-user-soft-delete/index.js';
1110
import KeyValueAdapterRam from '../../adapters/adminforth-key-value-adapter-ram/index.js';
1211
import OAuthPlugin from './configs/oauthPluginConfig.js';
12+
import TwoFactorsAuthPlugin from './configs/twoFactorAuthPluginConfig.js';
1313
import EmailInvitePlugin from '../../plugins/adminforth-email-invite/index.js';
1414
import EmailPasswordResetPlugin from '../../plugins/adminforth-email-password-reset/index.js';
1515

@@ -132,39 +132,7 @@ export default {
132132
},
133133
],
134134
plugins: [
135-
new TwoFactorsAuthPlugin (
136-
{
137-
twoFaSecretFieldName: 'secret2fa',
138-
timeStepWindow: 1,
139-
stepUpMfaGracePeriodSeconds: 300,
140-
usersFilterToAllowSkipSetup: (adminUser: AdminUser) => {
141-
// allow skip setup 2FA for users which email is 'adminforth' or 'adminguest'
142-
return (true);
143-
},
144-
passkeys: {
145-
keyValueAdapter: new KeyValueAdapterRam(),
146-
credentialResourceID: "passkeys",
147-
credentialIdFieldName: "credential_id",
148-
credentialMetaFieldName: "meta",
149-
credentialUserIdFieldName: "user_id",
150-
settings: {
151-
expectedOrigin: "http://localhost:3123",
152-
rp: {
153-
name: "New Reality",
154-
},
155-
user: {
156-
nameField: "email",
157-
displayNameField: "email",
158-
},
159-
authenticatorSelection: {
160-
authenticatorAttachment: "both",
161-
requireResidentKey: true,
162-
userVerification: "required",
163-
},
164-
},
165-
}
166-
}
167-
),
135+
TwoFactorsAuthPlugin,
168136
new ForeignInlineListPlugin({
169137
foreignResourceId: 'cars_sl'
170138
}),
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import TwoFactorsAuthPlugin from "../../../plugins/adminforth-two-factors-auth/index.js";
2+
import KeyValueAdapterRam from '../../../adapters/adminforth-key-value-adapter-ram/index.js';
3+
import type { AdminUser } from '../../../adminforth/index.js';
4+
5+
6+
7+
export default new TwoFactorsAuthPlugin (
8+
{
9+
twoFaSecretFieldName: 'secret2fa',
10+
timeStepWindow: 1,
11+
stepUpMfaGracePeriodSeconds: 300,
12+
usersFilterToAllowSkipSetup: (adminUser: AdminUser) => {
13+
// allow skip setup 2FA for users which email is 'adminforth' or 'adminguest'
14+
return (true);
15+
},
16+
passkeys: {
17+
keyValueAdapter: new KeyValueAdapterRam(),
18+
credentialResourceID: "passkeys",
19+
credentialIdFieldName: "credential_id",
20+
credentialMetaFieldName: "meta",
21+
credentialUserIdFieldName: "user_id",
22+
settings: {
23+
expectedOrigin: "http://localhost:3123",
24+
rp: {
25+
name: "New Reality",
26+
},
27+
user: {
28+
nameField: "email",
29+
displayNameField: "email",
30+
},
31+
authenticatorSelection: {
32+
authenticatorAttachment: "both",
33+
requireResidentKey: true,
34+
userVerification: "required",
35+
},
36+
},
37+
}
38+
}
39+
)

0 commit comments

Comments
 (0)