adminforth 1.1.74 → 1.1.76
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/auth.ts +14 -0
- package/dataConnectors/postgres.ts +1 -1
- package/dist/auth.js +7 -0
- package/dist/index.js +117 -65
- package/dist/modules/codeInjector.js +29 -15
- package/dist/modules/utils.js +1 -1
- package/dist/plugins/AuditLogPlugin/index.js +2 -17
- package/dist/plugins/S3UploadPlugin/custom/s3uploader.vue +120 -0
- package/dist/plugins/S3UploadPlugin/index.js +103 -0
- package/dist/plugins/S3UploadPlugin/package-lock.json +431 -0
- package/dist/plugins/S3UploadPlugin/package.json +16 -0
- package/dist/plugins/TwoFactorsAuthPlugin/custom/TwoFactorsConfirmation.vue +152 -0
- package/dist/plugins/TwoFactorsAuthPlugin/custom/TwoFactorsOtp.vue +0 -0
- package/dist/plugins/TwoFactorsAuthPlugin/custom/TwoFactorsSetup.vue +188 -0
- package/dist/plugins/TwoFactorsAuthPlugin/index.js +150 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/.package-lock.json +61 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/LICENSE +21 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/README.md +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/package.json +217 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/LICENSE +21 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/README.md +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/package.json +21 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/LICENSE +201 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/README.md +68 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/index.js +51 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/interfaces.js +2 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/package.json +58 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/.travis.yml +6 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/LICENSE +22 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/Readme.md +135 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/examples/TOTP-verify.js +33 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/examples/TOTP.js +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/index.js +221 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/package.json +22 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/test/mocha.opts +1 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/notp/test/notp.js +217 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/LICENSE.txt +19 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/Makefile +24 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/README.md +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/index.js +23 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/lib/thirty-two/index.js +26 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/lib/thirty-two/thirty-two.js +128 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/package.json +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/spec/thirty-two_spec.js +63 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/LICENSE.txt +12 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/README.md +164 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/SECURITY.md +41 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/index.js +68 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/package.json +3 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/package.json +47 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.html +1 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.js +374 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.mjs +373 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.html +1 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.js +424 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/README.md +6 -0
- package/dist/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/package.json +55 -0
- package/dist/plugins/TwoFactorsAuthPlugin/package-lock.json +69 -0
- package/dist/plugins/TwoFactorsAuthPlugin/package.json +15 -0
- package/dist/plugins/TwoFactorsAuthPlugin/types.js +1 -0
- package/dist/spa/index.html +1 -1
- package/dist/spa/package-lock.json +111 -0
- package/dist/spa/package.json +1 -0
- package/dist/spa/spa/src/App.vue +154 -121
- package/dist/spa/spa/src/components/ResourceForm.vue +91 -91
- package/dist/spa/spa/src/router/index.ts +0 -1
- package/dist/spa/spa/src/utils.ts +1 -1
- package/dist/spa/spa/src/views/CreateView.vue +0 -1
- package/dist/spa/spa/src/views/LoginView.vue +4 -1
- package/dist/spa/src/App.vue +178 -133
- package/dist/spa/src/components/MenuLink.vue +3 -3
- package/dist/spa/src/components/ResourceForm.vue +96 -96
- package/dist/spa/src/components/ResourceListTable.vue +69 -84
- package/dist/spa/src/components/SkeleteLoader.vue +23 -0
- package/dist/spa/src/components/ValueRenderer.vue +2 -3
- package/dist/spa/src/composables/useStores.ts +24 -11
- package/dist/spa/src/main.ts +1 -1
- package/dist/spa/src/router/index.ts +0 -1
- package/dist/spa/src/utils.ts +1 -1
- package/dist/spa/src/views/CreateView.vue +1 -9
- package/dist/spa/src/views/EditView.vue +1 -9
- package/dist/spa/src/views/ListView.vue +12 -3
- package/dist/spa/src/views/LoginView.vue +6 -1
- package/dist/spa/src/views/ResourceParent.vue +1 -2
- package/dist/spa/src/views/ShowView.vue +6 -14
- package/dist/spa/tailwind.config.js +3 -1
- package/index.ts +94 -35
- package/modules/codeInjector.ts +38 -27
- package/modules/utils.ts +1 -1
- package/package.json +1 -1
- package/plugins/AuditLogPlugin/index.ts +4 -20
- package/plugins/S3UploadPlugin/custom/s3uploader.vue +120 -0
- package/plugins/S3UploadPlugin/index.ts +112 -0
- package/plugins/S3UploadPlugin/package-lock.json +431 -0
- package/plugins/S3UploadPlugin/package.json +16 -0
- package/plugins/S3UploadPlugin/types.ts +76 -0
- package/plugins/TwoFactorsAuthPlugin/custom/TwoFactorsConfirmation.vue +152 -0
- package/plugins/TwoFactorsAuthPlugin/custom/TwoFactorsOtp.vue +0 -0
- package/plugins/TwoFactorsAuthPlugin/custom/TwoFactorsSetup.vue +188 -0
- package/plugins/TwoFactorsAuthPlugin/index.ts +150 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/.package-lock.json +61 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/LICENSE +21 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/README.md +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/assert.d.ts +1040 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/buffer.d.ts +2363 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/child_process.d.ts +1544 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/cluster.d.ts +578 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/console.d.ts +452 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/constants.d.ts +19 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/crypto.d.ts +4523 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/dgram.d.ts +596 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/dns/promises.d.ts +476 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/dns.d.ts +864 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/dom-events.d.ts +124 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/domain.d.ts +170 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/events.d.ts +931 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/fs/promises.d.ts +1245 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/fs.d.ts +4317 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/globals.d.ts +412 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/globals.global.d.ts +1 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/http.d.ts +1908 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/http2.d.ts +2418 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/https.d.ts +550 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/index.d.ts +89 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/inspector.d.ts +2746 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/module.d.ts +315 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/net.d.ts +999 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/os.d.ts +495 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/package.json +217 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/path.d.ts +191 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/perf_hooks.d.ts +905 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/process.d.ts +1754 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/punycode.d.ts +117 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/querystring.d.ts +153 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/readline.d.ts +540 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/repl.d.ts +430 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/sea.d.ts +153 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/stream/web.d.ts +367 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/stream.d.ts +1707 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/test.d.ts +1718 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/timers.d.ts +240 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/tls.d.ts +1217 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/trace_events.d.ts +197 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/tty.d.ts +208 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/url.d.ts +952 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/util.d.ts +2292 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/v8.d.ts +808 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/vm.d.ts +924 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/wasi.d.ts +181 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/worker_threads.d.ts +694 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/node/zlib.d.ts +530 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/LICENSE +21 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/README.md +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/index.d.ts +127 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/@types/notp/package.json +21 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/LICENSE +201 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/README.md +68 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/index.d.ts +11 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/index.js +51 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/interfaces.d.ts +4 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/dist/interfaces.js +2 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/node-2fa/package.json +58 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/.travis.yml +6 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/LICENSE +22 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/Readme.md +135 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/examples/TOTP-verify.js +33 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/examples/TOTP.js +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/index.js +221 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/package.json +22 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/test/mocha.opts +1 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/notp/test/notp.js +217 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/LICENSE.txt +19 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/Makefile +24 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/README.md +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/index.js +23 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/lib/thirty-two/index.js +26 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/lib/thirty-two/thirty-two.js +128 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/package.json +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/thirty-two/spec/thirty-two_spec.js +63 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/LICENSE.txt +12 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/README.md +164 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/SECURITY.md +41 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/index.d.ts +37 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/index.js +68 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/modules/package.json +3 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/package.json +47 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.d.ts +453 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.html +1 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.js +374 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.es6.mjs +373 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.html +1 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/tslib/tslib.js +424 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/README.md +6 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/agent.d.ts +31 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/api.d.ts +43 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/cache.d.ts +36 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/client.d.ts +97 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/connector.d.ts +34 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/content-type.d.ts +21 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/cookies.d.ts +28 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/errors.d.ts +128 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/fetch.d.ts +209 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/file.d.ts +39 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/filereader.d.ts +54 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/formdata.d.ts +108 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/global-origin.d.ts +7 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/handlers.d.ts +9 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/header.d.ts +4 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/index.d.ts +63 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/interceptors.d.ts +5 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-client.d.ts +25 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/package.json +55 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/patch.d.ts +71 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/pool.d.ts +28 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/readable.d.ts +61 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/webidl.d.ts +220 -0
- package/plugins/TwoFactorsAuthPlugin/node_modules/undici-types/websocket.d.ts +131 -0
- package/plugins/TwoFactorsAuthPlugin/package-lock.json +69 -0
- package/plugins/TwoFactorsAuthPlugin/package.json +15 -0
- package/plugins/TwoFactorsAuthPlugin/types.ts +10 -0
- package/servers/express.ts +1 -0
- package/spa/src/App.vue +154 -121
- package/spa/src/components/ResourceForm.vue +91 -91
- package/spa/src/router/index.ts +0 -1
- package/spa/src/utils.ts +1 -1
- package/spa/src/views/CreateView.vue +0 -1
- package/spa/src/views/LoginView.vue +4 -1
- package/types/AdminForthConfig.ts +24 -3
- package/dist/plugins/AuditLog/index.js +0 -13
- /package/dist/plugins/{AuditLog → S3UploadPlugin}/types.js +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
|
|
2
|
+
export type PluginOptions = {
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* the name of the column where the path to the uploaded file is stored
|
|
6
|
+
*/
|
|
7
|
+
pathColumnName: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* the list of allowed file extensions
|
|
11
|
+
*/
|
|
12
|
+
allowedFileExtensions?: string[]; // allowed file extensions
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* the maximum file size in bytes
|
|
16
|
+
*/
|
|
17
|
+
maxFileSize?: number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* This plugin creates a virtual column on edit and create views
|
|
21
|
+
* where the user can upload a file. This is the label of that column
|
|
22
|
+
*
|
|
23
|
+
* Defaulted to 'Upload \<Name of the column defined in {@link pathColumnName}\>'
|
|
24
|
+
*/
|
|
25
|
+
uploadColumnLabel: string,
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* S3 bucket name where we will upload the files, e.g. 'my-bucket'
|
|
29
|
+
*/
|
|
30
|
+
s3Bucket: string,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* S3 region, e.g. 'us-east-1'
|
|
34
|
+
*/
|
|
35
|
+
s3Region: string,
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* S3 access key id
|
|
39
|
+
*/
|
|
40
|
+
s3AccessKeyId: string,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* S3 secret access key
|
|
44
|
+
*/
|
|
45
|
+
s3SecretAccessKey: string,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* ACL which will be set to uploaded file, e.g. 'public-read'
|
|
49
|
+
*/
|
|
50
|
+
s3ACL: string,
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The path where the file will be uploaded to the S3 bucket, same path will be stored in the database
|
|
54
|
+
* in the column specified in {@link pathColumnName}
|
|
55
|
+
*
|
|
56
|
+
* example:
|
|
57
|
+
*
|
|
58
|
+
* ```typescript
|
|
59
|
+
* s3Path: ({record, originalFilename}) => `/aparts/${record.id}/${originalFilename}`
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
s3Path: ({originalFilename, originalExtension, contentType}) => string,
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Used to display preview (if it is image) in list and show views.
|
|
67
|
+
* Defaulted to the AWS S3 presigned URL
|
|
68
|
+
* Example:
|
|
69
|
+
*
|
|
70
|
+
* ```typescript
|
|
71
|
+
* previewUrl: ({record, path}) => `https://my-bucket.s3.amazonaws.com/${path}`,
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
previewUrl?: ({s3Path}) => string,
|
|
76
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-800"
|
|
3
|
+
:style="coreStore.config?.loginBackgroundImage ? {
|
|
4
|
+
'background-image': 'url(' + loadFile(coreStore.config?.loginBackgroundImage) + ')',
|
|
5
|
+
'background-size': 'cover',
|
|
6
|
+
'background-position': 'center',
|
|
7
|
+
'background-blend-mode': 'darken'
|
|
8
|
+
}: {}"
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
<div id="authentication-modal" tabindex="-1" class=" overflow-y-auto overflow-x-hidden z-50 min-w-[00px] justify-center items-center md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
|
12
|
+
<div class="relative p-4 w-full max-w-md max-h-full">
|
|
13
|
+
<!-- Modal content -->
|
|
14
|
+
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black text-gray-500" >
|
|
15
|
+
<div class="p-8 w-full max-w-md max-h-full" >
|
|
16
|
+
<div class="m-3" >Please enter your authenticator code </div>
|
|
17
|
+
|
|
18
|
+
<form class="max-w-sm mx-auto mt-6 flex flex-col items-center ">
|
|
19
|
+
<div class="flex mb-2 space-x-2 rtl:space-x-reverse ">
|
|
20
|
+
<div>
|
|
21
|
+
<label for="code-1" class="sr-only">First code</label>
|
|
22
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-next="code-2" id="code-1" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
23
|
+
</div>
|
|
24
|
+
<div>
|
|
25
|
+
<label for="code-2" class="sr-only">Second code</label>
|
|
26
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-1" data-focus-input-next="code-3" id="code-2" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
27
|
+
</div>
|
|
28
|
+
<div>
|
|
29
|
+
<label for="code-3" class="sr-only">Third code</label>
|
|
30
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-2" data-focus-input-next="code-4" id="code-3" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
31
|
+
</div>
|
|
32
|
+
<div>
|
|
33
|
+
<label for="code-4" class="sr-only">Fourth code</label>
|
|
34
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-3" data-focus-input-next="code-5" id="code-4" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
35
|
+
</div>
|
|
36
|
+
<div>
|
|
37
|
+
<label for="code-5" class="sr-only">Fifth code</label>
|
|
38
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-4" data-focus-input-next="code-6" id="code-5" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
39
|
+
</div>
|
|
40
|
+
<div>
|
|
41
|
+
<label for="code-6" class="sr-only">Sixth code</label>
|
|
42
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-5" id="code-6" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<p id="helper-text-explanation" class="mt-2 text-sm text-gray-500 dark:text-gray-400"></p>
|
|
46
|
+
</form>
|
|
47
|
+
<button @click="()=>{router.push('./login')}" class="flex items-center justify-center gap-1 w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
|
48
|
+
>Cancel</button>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
<script setup>
|
|
61
|
+
|
|
62
|
+
import { onMounted, ref, watchEffect,computed } from 'vue';
|
|
63
|
+
import { useCoreStore } from '@/stores/core';
|
|
64
|
+
import { useUserStore } from '@/stores/user';
|
|
65
|
+
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
|
|
66
|
+
import { callAdminForthApi, loadFile } from '@/utils';
|
|
67
|
+
import { useRouter } from 'vue-router';
|
|
68
|
+
import { initFlowbite } from 'flowbite'
|
|
69
|
+
import { showErrorTost } from '@/composables/useFrontendApi';
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
const router = useRouter();
|
|
75
|
+
const inProgress = ref(false);
|
|
76
|
+
|
|
77
|
+
const coreStore = useCoreStore();
|
|
78
|
+
const user = useUserStore();
|
|
79
|
+
|
|
80
|
+
// use this simple function to automatically focus on the next input
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
const showPw = ref(false);
|
|
85
|
+
|
|
86
|
+
const error = ref(null);
|
|
87
|
+
const totp = ref({});
|
|
88
|
+
const totpJWT = ref(null);
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
function parseJwt(token) {
|
|
92
|
+
// Split the token into its parts
|
|
93
|
+
const base64Url = token.split('.')[1];
|
|
94
|
+
|
|
95
|
+
// Base64-decode the payload
|
|
96
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
97
|
+
const jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
|
|
98
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
99
|
+
}).join(''));
|
|
100
|
+
|
|
101
|
+
// Parse the JSON payload
|
|
102
|
+
return JSON.parse(jsonPayload);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
onMounted(async () => {
|
|
106
|
+
coreStore.getPublicConfig()
|
|
107
|
+
|
|
108
|
+
function focusNextInput(el, prevId, nextId) {
|
|
109
|
+
if (el.value.length === 0) {
|
|
110
|
+
if (prevId) {
|
|
111
|
+
document.getElementById(prevId).focus();
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
if (nextId) {
|
|
115
|
+
document.getElementById(nextId).focus();
|
|
116
|
+
} else {
|
|
117
|
+
sendCode()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
document.querySelectorAll('[data-focus-input-init]').forEach(function(element) {
|
|
123
|
+
element.addEventListener('keyup', function() {
|
|
124
|
+
const prevId = this.getAttribute('data-focus-input-prev');
|
|
125
|
+
const nextId = this.getAttribute('data-focus-input-next');
|
|
126
|
+
focusNextInput(this, prevId, nextId);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
async function sendCode () {
|
|
135
|
+
inProgress.value = true;
|
|
136
|
+
const code = document.getElementById('code-1').value + document.getElementById('code-2').value + document.getElementById('code-3').value + document.getElementById('code-4').value + document.getElementById('code-5').value + document.getElementById('code-6').value;
|
|
137
|
+
const resp = await callAdminForthApi({
|
|
138
|
+
method: 'POST',
|
|
139
|
+
path: '/plugin/twofa/confirmSetup',
|
|
140
|
+
body: {
|
|
141
|
+
code: code,
|
|
142
|
+
secret: null,
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
if (resp.allowedLogin){
|
|
146
|
+
router.push('/');
|
|
147
|
+
} else {
|
|
148
|
+
showErrorTost('Invalid code');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
</script>
|
|
152
|
+
|
|
File without changes
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-800"
|
|
3
|
+
:style="coreStore.config?.loginBackgroundImage ? {
|
|
4
|
+
'background-image': 'url(' + loadFile(coreStore.config?.loginBackgroundImage) + ')',
|
|
5
|
+
'background-size': 'cover',
|
|
6
|
+
'background-position': 'center',
|
|
7
|
+
'background-blend-mode': 'darken'
|
|
8
|
+
}: {}"
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
<div id="authentication-modal" tabindex="-1" class=" overflow-y-auto overflow-x-hidden z-50 min-w-[00px] justify-center items-center md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
|
12
|
+
<div class="relative p-4 w-full max-w-md max-h-full">
|
|
13
|
+
<!-- Modal content -->
|
|
14
|
+
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black text-gray-500" >
|
|
15
|
+
<div class="p-8 w-full max-w-md max-h-full" >
|
|
16
|
+
<div class="m-3" >Scan this QR code with your authenticator app or open by <a class="text-blue-600" :href="totpUri">click</a></div>
|
|
17
|
+
<div class="flex justify-center m-3" >
|
|
18
|
+
<img :src="totpQrCode" alt="QR code" />
|
|
19
|
+
</div>
|
|
20
|
+
<div class="m-3 ">
|
|
21
|
+
<div class="m-1">Or copy this code to app manually:</div>
|
|
22
|
+
<div class="w-full max-w-[46rem]">
|
|
23
|
+
<div class="relative">
|
|
24
|
+
<label for="npm-install-copy-text" class="sr-only">Label</label>
|
|
25
|
+
<input id="npm-install-copy-text" type="text" class="col-span-10 bg-gray-50 border border-gray-300 text-gray-500 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full px-2.5 py-4 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-gray-400 dark:focus:ring-blue-500 dark:focus:border-blue-500" :value="totp.newSecret" disabled readonly>
|
|
26
|
+
<button data-copy-to-clipboard-target="npm-install-copy-text" class="absolute end-2.5 top-1/2 -translate-y-1/2 text-gray-900 dark:text-gray-400 hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-600 dark:hover:bg-gray-700 rounded-lg py-2 px-2.5 inline-flex items-center justify-center bg-white border-gray-200 border">
|
|
27
|
+
<span id="default-message" class="inline-flex items-center">
|
|
28
|
+
<svg class="w-3 h-3 me-1.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 18 20">
|
|
29
|
+
<path d="M16 1h-3.278A1.992 1.992 0 0 0 11 0H7a1.993 1.993 0 0 0-1.722 1H2a2 2 0 0 0-2 2v15a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2Zm-3 14H5a1 1 0 0 1 0-2h8a1 1 0 0 1 0 2Zm0-4H5a1 1 0 0 1 0-2h8a1 1 0 1 1 0 2Zm0-5H5a1 1 0 0 1 0-2h2V2h4v2h2a1 1 0 1 1 0 2Z"/>
|
|
30
|
+
</svg>
|
|
31
|
+
<span class="text-xs font-semibold">Copy</span>
|
|
32
|
+
</span>
|
|
33
|
+
<span id="success-message" class="hidden inline-flex items-center">
|
|
34
|
+
<svg class="w-3 h-3 text-blue-700 dark:text-blue-500 me-1.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 12">
|
|
35
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 5.917 5.724 10.5 15 1.5"/>
|
|
36
|
+
</svg>
|
|
37
|
+
<span class="text-xs font-semibold text-blue-700 dark:text-blue-500">Copied</span>
|
|
38
|
+
</span>
|
|
39
|
+
</button>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
<form class="max-w-sm mx-auto mt-6 flex flex-col items-center ">
|
|
44
|
+
<div class="flex mb-2 space-x-2 rtl:space-x-reverse ">
|
|
45
|
+
<div>
|
|
46
|
+
<label for="code-1" class="sr-only">First code</label>
|
|
47
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-next="code-2" id="code-1" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
48
|
+
</div>
|
|
49
|
+
<div>
|
|
50
|
+
<label for="code-2" class="sr-only">Second code</label>
|
|
51
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-1" data-focus-input-next="code-3" id="code-2" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
52
|
+
</div>
|
|
53
|
+
<div>
|
|
54
|
+
<label for="code-3" class="sr-only">Third code</label>
|
|
55
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-2" data-focus-input-next="code-4" id="code-3" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
56
|
+
</div>
|
|
57
|
+
<div>
|
|
58
|
+
<label for="code-4" class="sr-only">Fourth code</label>
|
|
59
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-3" data-focus-input-next="code-5" id="code-4" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
60
|
+
</div>
|
|
61
|
+
<div>
|
|
62
|
+
<label for="code-5" class="sr-only">Fifth code</label>
|
|
63
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-4" data-focus-input-next="code-6" id="code-5" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
64
|
+
</div>
|
|
65
|
+
<div>
|
|
66
|
+
<label for="code-6" class="sr-only">Sixth code</label>
|
|
67
|
+
<input type="text" maxlength="1" data-focus-input-init data-focus-input-prev="code-5" id="code-6" class="block w-9 h-9 py-3 text-sm font-extrabold text-center text-gray-900 bg-white border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" required />
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<p id="helper-text-explanation" class="mt-2 text-sm text-gray-500 dark:text-gray-400"></p>
|
|
71
|
+
</form>
|
|
72
|
+
<button @click="()=>{router.push('./login')}" class="flex items-center justify-center gap-1 w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Cancel</button>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
<script setup>
|
|
85
|
+
|
|
86
|
+
import { onMounted, ref, watchEffect,computed } from 'vue';
|
|
87
|
+
import { useCoreStore } from '@/stores/core';
|
|
88
|
+
import { useUserStore } from '@/stores/user';
|
|
89
|
+
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
|
|
90
|
+
import { callAdminForthApi, loadFile } from '@/utils';
|
|
91
|
+
import { useRouter } from 'vue-router';
|
|
92
|
+
import { initFlowbite } from 'flowbite'
|
|
93
|
+
import { showErrorTost } from '@/composables/useFrontendApi';
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
const router = useRouter();
|
|
99
|
+
const inProgress = ref(false);
|
|
100
|
+
|
|
101
|
+
const coreStore = useCoreStore();
|
|
102
|
+
const user = useUserStore();
|
|
103
|
+
|
|
104
|
+
// use this simple function to automatically focus on the next input
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
const showPw = ref(false);
|
|
109
|
+
|
|
110
|
+
const error = ref(null);
|
|
111
|
+
const totp = ref({});
|
|
112
|
+
const totpJWT = ref(null);
|
|
113
|
+
const totpUri = computed(() => {
|
|
114
|
+
if (totp.value) {
|
|
115
|
+
return `otpauth://totp/${totp.value.issuer}:${totp.value.userName}?secret=${totp.value.newSecret}&issuer=${totp.value.issuer}`;
|
|
116
|
+
}});
|
|
117
|
+
const totpQrCode = computed(() => {
|
|
118
|
+
if (totpUri.value) {
|
|
119
|
+
return `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(totpUri.value)}`;
|
|
120
|
+
}});
|
|
121
|
+
|
|
122
|
+
function parseJwt(token) {
|
|
123
|
+
// Split the token into its parts
|
|
124
|
+
const base64Url = token.split('.')[1];
|
|
125
|
+
|
|
126
|
+
// Base64-decode the payload
|
|
127
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
128
|
+
const jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
|
|
129
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
130
|
+
}).join(''));
|
|
131
|
+
|
|
132
|
+
// Parse the JSON payload
|
|
133
|
+
return JSON.parse(jsonPayload);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
onMounted(async () => {
|
|
137
|
+
coreStore.getPublicConfig()
|
|
138
|
+
const resp = await callAdminForthApi({
|
|
139
|
+
path: '/plugin/twofa/initSetup',
|
|
140
|
+
method: 'POST',});
|
|
141
|
+
if (resp && resp.totpJWT){
|
|
142
|
+
totpJWT.value = resp.totpJWT;
|
|
143
|
+
}
|
|
144
|
+
function focusNextInput(el, prevId, nextId) {
|
|
145
|
+
if (el.value.length === 0) {
|
|
146
|
+
if (prevId) {
|
|
147
|
+
document.getElementById(prevId).focus();
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
if (nextId) {
|
|
151
|
+
document.getElementById(nextId).focus();
|
|
152
|
+
} else {
|
|
153
|
+
sendCode()
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
document.querySelectorAll('[data-focus-input-init]').forEach(function(element) {
|
|
159
|
+
element.addEventListener('keyup', function() {
|
|
160
|
+
const prevId = this.getAttribute('data-focus-input-prev');
|
|
161
|
+
const nextId = this.getAttribute('data-focus-input-next');
|
|
162
|
+
focusNextInput(this, prevId, nextId);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
totp.value=parseJwt(totpJWT.value);
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
async function sendCode () {
|
|
172
|
+
inProgress.value = true;
|
|
173
|
+
const code = document.getElementById('code-1').value + document.getElementById('code-2').value + document.getElementById('code-3').value + document.getElementById('code-4').value + document.getElementById('code-5').value + document.getElementById('code-6').value;
|
|
174
|
+
const resp = await callAdminForthApi({
|
|
175
|
+
method: 'POST',
|
|
176
|
+
path: '/plugin/twofa/confirmSetup',
|
|
177
|
+
body: {
|
|
178
|
+
code: code,
|
|
179
|
+
secret: totp.value.newSecret,
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
if (resp.allowedLogin){
|
|
183
|
+
router.push('/');
|
|
184
|
+
} else {
|
|
185
|
+
showErrorTost('Invalid code');
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
</script>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { AdminForthResource, AdminForthResourcePages, AdminForthClass, GenericHttpServer } from "../../types/AdminForthConfig.js";
|
|
2
|
+
import AdminForthPlugin from "../base.js";
|
|
3
|
+
import twofactor from 'node-2fa';
|
|
4
|
+
import AdminForthAuth from "../../auth.js";
|
|
5
|
+
import { PluginOptions } from "./types.js"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
9
|
+
options: PluginOptions;
|
|
10
|
+
adminforth: AdminForthClass;
|
|
11
|
+
authResource: AdminForthResource;
|
|
12
|
+
connectors: any;
|
|
13
|
+
adminForthAuth: AdminForthAuth ;
|
|
14
|
+
|
|
15
|
+
constructor(options: PluginOptions) {
|
|
16
|
+
super(options, import.meta.url);
|
|
17
|
+
this.options = options;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
modifyResourceConfig(adminforth: AdminForthClass, resourceConfig: AdminForthResource) {
|
|
21
|
+
super.modifyResourceConfig(adminforth, resourceConfig);
|
|
22
|
+
this.adminforth = adminforth;
|
|
23
|
+
this.adminForthAuth = new AdminForthAuth(adminforth)
|
|
24
|
+
const customPages = this.adminforth.config.customization.customPages
|
|
25
|
+
customPages.push({
|
|
26
|
+
path:'/confirm2fa',
|
|
27
|
+
component: { file: this.componentPath('TwoFactorsConfirmation.vue'), meta: { customLayout: true }}
|
|
28
|
+
})
|
|
29
|
+
customPages.push({
|
|
30
|
+
path:'/setup2fa',
|
|
31
|
+
component: { file: this.componentPath('TwoFactorsSetup.vue'), meta: { title: 'Setup 2FA', customLayout: true }}
|
|
32
|
+
})
|
|
33
|
+
this.activate( resourceConfig,adminforth )
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
activate ( resourceConfig: AdminForthResource, adminforth: AdminForthClass ){
|
|
37
|
+
if (!this.options.twoFaSecretFieldName){
|
|
38
|
+
throw new Error('twoFaSecretFieldName is required')
|
|
39
|
+
}
|
|
40
|
+
if (typeof this.options.twoFaSecretFieldName !=='string'){
|
|
41
|
+
throw new Error('twoFaSecretFieldName must be a string')
|
|
42
|
+
}
|
|
43
|
+
this.authResource = resourceConfig
|
|
44
|
+
if(!this.authResource.columns.some((col)=>col.name === this.options.twoFaSecretFieldName)){
|
|
45
|
+
throw new Error(`Column ${this.options.twoFaSecretFieldName} not found in ${this.authResource.label}`)
|
|
46
|
+
}
|
|
47
|
+
const beforeLoginConfirmation = this.adminforth.config.auth as any
|
|
48
|
+
if (!beforeLoginConfirmation.beforeLoginConfirmation){
|
|
49
|
+
beforeLoginConfirmation.beforeLoginConfirmation = []
|
|
50
|
+
}
|
|
51
|
+
beforeLoginConfirmation.beforeLoginConfirmation.push(async({adminUser})=>{
|
|
52
|
+
if(adminUser.isRoot){
|
|
53
|
+
return { body: {loginAllowed: true}, ok: true}
|
|
54
|
+
}
|
|
55
|
+
const secret = adminUser.dbUser[this.options.twoFaSecretFieldName]
|
|
56
|
+
const userName = adminUser.dbUser[adminforth.config.auth.usernameField]
|
|
57
|
+
const brandName = adminforth.config.customization.brandName
|
|
58
|
+
const authResource = adminforth.config.resources.find((res)=>res.resourceId === adminforth.config.auth.resourceId )
|
|
59
|
+
const authPk = authResource.columns.find((col)=>col.primaryKey).name
|
|
60
|
+
const userPk = adminUser.dbUser[authPk]
|
|
61
|
+
let newSecret = null
|
|
62
|
+
if (!secret){
|
|
63
|
+
const tempSecret = twofactor.generateSecret({name: brandName,account: userName})
|
|
64
|
+
newSecret = tempSecret.secret
|
|
65
|
+
} else {
|
|
66
|
+
return {
|
|
67
|
+
body:{
|
|
68
|
+
loginAllowed: false,
|
|
69
|
+
redirectTo: '/confirm2fa',
|
|
70
|
+
setCookie: [{
|
|
71
|
+
name: 'totpTemporaryJWT',
|
|
72
|
+
value: this.adminforth.auth.issueJWT({userName, issuer:brandName, pk:userPk },'tempTotp', ),
|
|
73
|
+
expiry: '1h',
|
|
74
|
+
httpOnly: true
|
|
75
|
+
},]
|
|
76
|
+
},
|
|
77
|
+
ok: true
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const totpTemporaryJWT = this.adminforth.auth.issueJWT({userName, newSecret, issuer:brandName, pk:userPk },'tempTotp', )
|
|
82
|
+
return {
|
|
83
|
+
body:{
|
|
84
|
+
loginAllowed: false,
|
|
85
|
+
redirectTo: secret ? '/confirm2fa' : '/setup2fa',
|
|
86
|
+
setCookie: [{
|
|
87
|
+
name: 'totpTemporaryJWT',
|
|
88
|
+
value: totpTemporaryJWT,
|
|
89
|
+
expiry: '1h',
|
|
90
|
+
httpOnly: true
|
|
91
|
+
},]},
|
|
92
|
+
ok: true
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setupEndpoints(server: GenericHttpServer): void {
|
|
98
|
+
server.endpoint({
|
|
99
|
+
method: 'POST',
|
|
100
|
+
path: `/plugin/twofa/initSetup`,
|
|
101
|
+
noAuth: true,
|
|
102
|
+
handler: async (server) => {
|
|
103
|
+
const toReturn = {totpJWT:null,status:'ok',}
|
|
104
|
+
const totpTemporaryJWT = server.cookies['adminforth_totpTemporaryJWT']
|
|
105
|
+
if (totpTemporaryJWT){
|
|
106
|
+
toReturn.totpJWT = totpTemporaryJWT
|
|
107
|
+
}
|
|
108
|
+
return toReturn
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
server.endpoint({
|
|
112
|
+
method: 'POST',
|
|
113
|
+
path: `/plugin/twofa/confirmSetup`,
|
|
114
|
+
noAuth: true,
|
|
115
|
+
handler: async ({ body, adminUser, response, cookies }) => {
|
|
116
|
+
const totpTemporaryJWT = cookies['adminforth_totpTemporaryJWT']
|
|
117
|
+
const decoded = await this.adminforth.auth.verify(totpTemporaryJWT, 'tempTotp');
|
|
118
|
+
if ( !decoded ) {
|
|
119
|
+
return {status:'error',message:'Invalid token'}
|
|
120
|
+
}
|
|
121
|
+
if (decoded.newSecret) {
|
|
122
|
+
const verified = twofactor.verifyToken(decoded.newSecret, body.code);
|
|
123
|
+
if (verified) {
|
|
124
|
+
this.connectors = this.adminforth.connectors
|
|
125
|
+
const connector = this.connectors[this.authResource.dataSource];
|
|
126
|
+
await connector.updateRecord({resource:this.authResource, recordId:decoded.pk, newValues:{[this.options.twoFaSecretFieldName]: decoded.newSecret}})
|
|
127
|
+
this.adminForthAuth.removeCustomCookie({response, name:'totpTemporaryJWT'})
|
|
128
|
+
this.adminForthAuth.setAuthCookie({response, username:decoded.userName, pk:decoded.pk})
|
|
129
|
+
return { status: 'ok',allowedLogin: true }
|
|
130
|
+
} else {
|
|
131
|
+
return {error: 'Wrong or expired OTP code'}
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
// user already has secret, get it
|
|
135
|
+
this.connectors = this.adminforth.connectors
|
|
136
|
+
const connector = this.connectors[this.authResource.dataSource];
|
|
137
|
+
const user = await connector.getRecordByPrimaryKey(this.authResource, decoded.pk)
|
|
138
|
+
const verified = twofactor.verifyToken(user[this.options.twoFaSecretFieldName], body.code);
|
|
139
|
+
if (verified) {
|
|
140
|
+
this.adminForthAuth.removeCustomCookie({response, name:'totpTemporaryJWT'})
|
|
141
|
+
this.adminForthAuth.setAuthCookie({response, username:decoded.userName, pk:decoded.pk})
|
|
142
|
+
return { status: 'ok',allowedLogin: true }
|
|
143
|
+
} else {
|
|
144
|
+
return {error: 'Wrong or expired OTP code'}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "twofactorsauthplugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"node_modules/@types/node": {
|
|
8
|
+
"version": "20.14.9",
|
|
9
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz",
|
|
10
|
+
"integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"undici-types": "~5.26.4"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"node_modules/@types/notp": {
|
|
16
|
+
"version": "2.0.5",
|
|
17
|
+
"resolved": "https://registry.npmjs.org/@types/notp/-/notp-2.0.5.tgz",
|
|
18
|
+
"integrity": "sha512-ZsZS0PYUa6ZE4K3yOGerBvaxCp4ePf6ZmkFbPeilcqz2Ui/lmXox7KlRt7XZkXzqUgXhFLkc09ixyVmFLCU3gQ==",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@types/node": "*"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"node_modules/node-2fa": {
|
|
24
|
+
"version": "2.0.3",
|
|
25
|
+
"resolved": "https://registry.npmjs.org/node-2fa/-/node-2fa-2.0.3.tgz",
|
|
26
|
+
"integrity": "sha512-PQldrOhjuoZyoydMvMSctllPN1ZPZ1/NwkEcgYwY9faVqE/OymxR+3awPpbWZxm6acLKqvmNqQmdqTsqYyflFw==",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@types/notp": "^2.0.0",
|
|
29
|
+
"notp": "^2.0.3",
|
|
30
|
+
"thirty-two": "1.0.2",
|
|
31
|
+
"tslib": "^2.1.0"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"node_modules/notp": {
|
|
35
|
+
"version": "2.0.3",
|
|
36
|
+
"resolved": "https://registry.npmjs.org/notp/-/notp-2.0.3.tgz",
|
|
37
|
+
"integrity": "sha512-oBig/2uqkjQ5AkBuw4QJYwkEWa/q+zHxI5/I5z6IeP2NT0alpJFsP/trrfCC+9xOAgQSZXssNi962kp5KBmypQ==",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": "> v0.6.0"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"node_modules/thirty-two": {
|
|
43
|
+
"version": "1.0.2",
|
|
44
|
+
"resolved": "https://registry.npmjs.org/thirty-two/-/thirty-two-1.0.2.tgz",
|
|
45
|
+
"integrity": "sha512-OEI0IWCe+Dw46019YLl6V10Us5bi574EvlJEOcAkB29IzQ/mYD1A6RyNHLjZPiHCmuodxvgF6U+vZO1L15lxVA==",
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=0.2.6"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"node_modules/tslib": {
|
|
51
|
+
"version": "2.6.3",
|
|
52
|
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz",
|
|
53
|
+
"integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ=="
|
|
54
|
+
},
|
|
55
|
+
"node_modules/undici-types": {
|
|
56
|
+
"version": "5.26.5",
|
|
57
|
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
|
58
|
+
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|