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,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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import AdminForthPlugin from "../base.js";
|
|
11
|
+
import twofactor from 'node-2fa';
|
|
12
|
+
import AdminForthAuth from "../../auth.js";
|
|
13
|
+
export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options, import.meta.url);
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
modifyResourceConfig(adminforth, resourceConfig) {
|
|
19
|
+
super.modifyResourceConfig(adminforth, resourceConfig);
|
|
20
|
+
this.adminforth = adminforth;
|
|
21
|
+
this.adminForthAuth = new AdminForthAuth(adminforth);
|
|
22
|
+
const customPages = this.adminforth.config.customization.customPages;
|
|
23
|
+
customPages.push({
|
|
24
|
+
path: '/confirm2fa',
|
|
25
|
+
component: { file: this.componentPath('TwoFactorsConfirmation.vue'), meta: { customLayout: true } }
|
|
26
|
+
});
|
|
27
|
+
customPages.push({
|
|
28
|
+
path: '/setup2fa',
|
|
29
|
+
component: { file: this.componentPath('TwoFactorsSetup.vue'), meta: { title: 'Setup 2FA', customLayout: true } }
|
|
30
|
+
});
|
|
31
|
+
this.activate(resourceConfig, adminforth);
|
|
32
|
+
}
|
|
33
|
+
activate(resourceConfig, adminforth) {
|
|
34
|
+
if (!this.options.twoFaSecretFieldName) {
|
|
35
|
+
throw new Error('twoFaSecretFieldName is required');
|
|
36
|
+
}
|
|
37
|
+
if (typeof this.options.twoFaSecretFieldName !== 'string') {
|
|
38
|
+
throw new Error('twoFaSecretFieldName must be a string');
|
|
39
|
+
}
|
|
40
|
+
this.authResource = resourceConfig;
|
|
41
|
+
if (!this.authResource.columns.some((col) => col.name === this.options.twoFaSecretFieldName)) {
|
|
42
|
+
throw new Error(`Column ${this.options.twoFaSecretFieldName} not found in ${this.authResource.label}`);
|
|
43
|
+
}
|
|
44
|
+
const beforeLoginConfirmation = this.adminforth.config.auth;
|
|
45
|
+
if (!beforeLoginConfirmation.beforeLoginConfirmation) {
|
|
46
|
+
beforeLoginConfirmation.beforeLoginConfirmation = [];
|
|
47
|
+
}
|
|
48
|
+
beforeLoginConfirmation.beforeLoginConfirmation.push((_a) => __awaiter(this, [_a], void 0, function* ({ adminUser }) {
|
|
49
|
+
if (adminUser.isRoot) {
|
|
50
|
+
return { body: { loginAllowed: true }, ok: true };
|
|
51
|
+
}
|
|
52
|
+
const secret = adminUser.dbUser[this.options.twoFaSecretFieldName];
|
|
53
|
+
const userName = adminUser.dbUser[adminforth.config.auth.usernameField];
|
|
54
|
+
const brandName = adminforth.config.customization.brandName;
|
|
55
|
+
const authResource = adminforth.config.resources.find((res) => res.resourceId === adminforth.config.auth.resourceId);
|
|
56
|
+
const authPk = authResource.columns.find((col) => col.primaryKey).name;
|
|
57
|
+
const userPk = adminUser.dbUser[authPk];
|
|
58
|
+
let newSecret = null;
|
|
59
|
+
if (!secret) {
|
|
60
|
+
const tempSecret = twofactor.generateSecret({ name: brandName, account: userName });
|
|
61
|
+
newSecret = tempSecret.secret;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return {
|
|
65
|
+
body: {
|
|
66
|
+
loginAllowed: false,
|
|
67
|
+
redirectTo: '/confirm2fa',
|
|
68
|
+
setCookie: [{
|
|
69
|
+
name: 'totpTemporaryJWT',
|
|
70
|
+
value: this.adminforth.auth.issueJWT({ userName, issuer: brandName, pk: userPk }, 'tempTotp'),
|
|
71
|
+
expiry: '1h',
|
|
72
|
+
httpOnly: true
|
|
73
|
+
},]
|
|
74
|
+
},
|
|
75
|
+
ok: true
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const totpTemporaryJWT = this.adminforth.auth.issueJWT({ userName, newSecret, issuer: brandName, pk: userPk }, 'tempTotp');
|
|
79
|
+
return {
|
|
80
|
+
body: {
|
|
81
|
+
loginAllowed: false,
|
|
82
|
+
redirectTo: secret ? '/confirm2fa' : '/setup2fa',
|
|
83
|
+
setCookie: [{
|
|
84
|
+
name: 'totpTemporaryJWT',
|
|
85
|
+
value: totpTemporaryJWT,
|
|
86
|
+
expiry: '1h',
|
|
87
|
+
httpOnly: true
|
|
88
|
+
},]
|
|
89
|
+
},
|
|
90
|
+
ok: true
|
|
91
|
+
};
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
setupEndpoints(server) {
|
|
95
|
+
server.endpoint({
|
|
96
|
+
method: 'POST',
|
|
97
|
+
path: `/plugin/twofa/initSetup`,
|
|
98
|
+
noAuth: true,
|
|
99
|
+
handler: (server) => __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const toReturn = { totpJWT: null, status: 'ok', };
|
|
101
|
+
const totpTemporaryJWT = server.cookies['adminforth_totpTemporaryJWT'];
|
|
102
|
+
if (totpTemporaryJWT) {
|
|
103
|
+
toReturn.totpJWT = totpTemporaryJWT;
|
|
104
|
+
}
|
|
105
|
+
return toReturn;
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
server.endpoint({
|
|
109
|
+
method: 'POST',
|
|
110
|
+
path: `/plugin/twofa/confirmSetup`,
|
|
111
|
+
noAuth: true,
|
|
112
|
+
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, response, cookies }) {
|
|
113
|
+
const totpTemporaryJWT = cookies['adminforth_totpTemporaryJWT'];
|
|
114
|
+
const decoded = yield this.adminforth.auth.verify(totpTemporaryJWT, 'tempTotp');
|
|
115
|
+
if (!decoded) {
|
|
116
|
+
return { status: 'error', message: 'Invalid token' };
|
|
117
|
+
}
|
|
118
|
+
if (decoded.newSecret) {
|
|
119
|
+
const verified = twofactor.verifyToken(decoded.newSecret, body.code);
|
|
120
|
+
if (verified) {
|
|
121
|
+
this.connectors = this.adminforth.connectors;
|
|
122
|
+
const connector = this.connectors[this.authResource.dataSource];
|
|
123
|
+
yield connector.updateRecord({ resource: this.authResource, recordId: decoded.pk, newValues: { [this.options.twoFaSecretFieldName]: decoded.newSecret } });
|
|
124
|
+
this.adminForthAuth.removeCustomCookie({ response, name: 'totpTemporaryJWT' });
|
|
125
|
+
this.adminForthAuth.setAuthCookie({ response, username: decoded.userName, pk: decoded.pk });
|
|
126
|
+
return { status: 'ok', allowedLogin: true };
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return { error: 'Wrong or expired OTP code' };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// user already has secret, get it
|
|
134
|
+
this.connectors = this.adminforth.connectors;
|
|
135
|
+
const connector = this.connectors[this.authResource.dataSource];
|
|
136
|
+
const user = yield connector.getRecordByPrimaryKey(this.authResource, decoded.pk);
|
|
137
|
+
const verified = twofactor.verifyToken(user[this.options.twoFaSecretFieldName], body.code);
|
|
138
|
+
if (verified) {
|
|
139
|
+
this.adminForthAuth.removeCustomCookie({ response, name: 'totpTemporaryJWT' });
|
|
140
|
+
this.adminForthAuth.setAuthCookie({ response, username: decoded.userName, pk: decoded.pk });
|
|
141
|
+
return { status: 'ok', allowedLogin: true };
|
|
142
|
+
}
|
|
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
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
> `npm install --save @types/node`
|
|
3
|
+
|
|
4
|
+
# Summary
|
|
5
|
+
This package contains type definitions for node (https://nodejs.org/).
|
|
6
|
+
|
|
7
|
+
# Details
|
|
8
|
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
|
+
|
|
10
|
+
### Additional Details
|
|
11
|
+
* Last updated: Tue, 25 Jun 2024 22:07:01 GMT
|
|
12
|
+
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
|
13
|
+
|
|
14
|
+
# Credits
|
|
15
|
+
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).
|