From 10191386488119b2c678925253bbaa098e1148e8 Mon Sep 17 00:00:00 2001 From: Adrian Rudnik Date: Thu, 23 Nov 2023 22:41:17 +0100 Subject: [PATCH] Introduce admin and guest context (#33) Implements and fixes #32 --- frontend/package-lock.json | 76 +- .../theme-base/components/menu/_menubar.scss | 2 +- .../themes/ablegram/_extensions.scss | 6 + .../components/auth/LoginWithPasswordForm.vue | 66 ++ frontend/src/components/auth/UserAvatar.vue | 46 + frontend/src/components/parts/MenuBar.vue | 70 +- .../components/search/SearchQueryToolbar.vue | 18 +- .../structure/form/PasswordInput.vue | 60 ++ frontend/src/layouts/AppLayout.vue | 5 +- frontend/src/layouts/FullscreenLayout.vue | 13 +- frontend/src/locales/en.yaml | 28 + frontend/src/plugins/api.ts | 12 +- frontend/src/plugins/search/result/index.ts | 2 +- frontend/src/router/index.ts | 13 + frontend/src/router/middleware/bootApp.ts | 4 + frontend/src/stores/session.ts | 54 ++ frontend/src/views/OtpAuthView.vue | 48 + service/crypt/crypt.go | 102 ++ service/flags.go | 15 + service/go.mod | 5 +- service/go.sum | 6 + service/internal/access/auth.go | 57 ++ service/internal/access/errors.go | 6 + service/internal/{auth => access}/logger.go | 2 +- service/internal/access/otp.go | 64 ++ service/internal/{auth => access}/password.go | 2 +- service/internal/auth/auth.go | 37 - service/internal/config/config.go | 24 +- service/internal/config/types.go | 9 +- service/internal/ui/opener.go | 17 +- service/internal/webservice/funcs.go | 17 + .../internal/webservice/middleware_auth.go | 31 + .../{middleware.go => middleware_cache.go} | 2 +- service/internal/webservice/routes_access.go | 98 ++ service/internal/webservice/routes_config.go | 45 +- service/internal/webservice/routes_os.go | 15 +- service/internal/webservice/server.go | 30 +- service/main.go | 11 +- website/docs/.vitepress/config.mts | 5 + website/docs/guests-and-server-access.md | 30 + website/docs/live-demo.md | 15 +- website/docs/service-arguments.md | 23 + website/docs/thanks/index.md | 27 + website/package-lock.json | 916 ++++++++++++++---- 44 files changed, 1779 insertions(+), 355 deletions(-) create mode 100644 frontend/src/components/auth/LoginWithPasswordForm.vue create mode 100644 frontend/src/components/auth/UserAvatar.vue create mode 100644 frontend/src/components/structure/form/PasswordInput.vue create mode 100644 frontend/src/stores/session.ts create mode 100644 frontend/src/views/OtpAuthView.vue create mode 100644 service/crypt/crypt.go create mode 100644 service/internal/access/auth.go create mode 100644 service/internal/access/errors.go rename service/internal/{auth => access}/logger.go (87%) create mode 100644 service/internal/access/otp.go rename service/internal/{auth => access}/password.go (97%) delete mode 100644 service/internal/auth/auth.go create mode 100644 service/internal/webservice/funcs.go create mode 100644 service/internal/webservice/middleware_auth.go rename service/internal/webservice/{middleware.go => middleware_cache.go} (93%) create mode 100644 service/internal/webservice/routes_access.go create mode 100644 website/docs/guests-and-server-access.md create mode 100644 website/docs/thanks/index.md diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 031046a3..3fa991fe 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -787,12 +787,12 @@ } }, "node_modules/@intlify/core-base": { - "version": "9.7.0", - "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.7.0.tgz", - "integrity": "sha512-1tBnfnCI23jXqGW15cagCjn2GgD487VST1dMG8P5LRzrSfx+kUzqFyTrjMNIwgq1tVaF4HnDpFMUuyrzTLKphw==", + "version": "9.7.1", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.7.1.tgz", + "integrity": "sha512-jPJTeECEhqQ7g//8g3Fb79j5SzSSRqlFCWD6pcX94uMLXU+L1m07gVZnnvzoJBnaMyJHiiwxOqZVfvu6rQfLvw==", "dependencies": { - "@intlify/message-compiler": "9.7.0", - "@intlify/shared": "9.7.0" + "@intlify/message-compiler": "9.7.1", + "@intlify/shared": "9.7.1" }, "engines": { "node": ">= 16" @@ -802,11 +802,11 @@ } }, "node_modules/@intlify/message-compiler": { - "version": "9.7.0", - "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.7.0.tgz", - "integrity": "sha512-/YdZCio2L2tCM5bZ2eMHbSEIQNPh1QqvZIOLI/yCVKXLscis7O0SsR2nmuU/DfCJ3iSeI8juw82C2wLvfsAeww==", + "version": "9.7.1", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.7.1.tgz", + "integrity": "sha512-HfIr2Hn/K7b0Zv4kGqkxAxwtipyxAwhI9a3krN5cuhH/G9gkaik7of1PdzjR3Mix43t2onBiKYQyaU7mo7e0aA==", "dependencies": { - "@intlify/shared": "9.7.0", + "@intlify/shared": "9.7.1", "source-map-js": "^1.0.2" }, "engines": { @@ -817,9 +817,9 @@ } }, "node_modules/@intlify/shared": { - "version": "9.7.0", - "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.7.0.tgz", - "integrity": "sha512-PUkEuk//YKu4CHS5ah3mNa3XL/+TZj6rAY/6yYN+GCNFd2u+uWUkeuwE4Q6t8dydRWlErOePHHS0KyNoof/oBw==", + "version": "9.7.1", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.7.1.tgz", + "integrity": "sha512-CBKnHzlUYGrk5QII9q4nElAQKO5cX1rRx8VmSWXltyOZjbkGHXYQTHULn6KwRi+CypuBCfmPkyPBHMzosypIeg==", "engines": { "node": ">= 16" }, @@ -949,9 +949,9 @@ } }, "node_modules/@rushstack/eslint-patch": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.5.1.tgz", - "integrity": "sha512-6i/8UoL0P5y4leBIGzvkZdS85RDMG9y1ihZzmTZQ5LdHUYmZ7pKFoj8X0236s3lusPs1Fa5HTQUpwI+UfTcmeA==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.6.0.tgz", + "integrity": "sha512-2/U3GXA6YiPYQDLGwtGlnNgKYBSwCFIHf8Y9LUY5VATHdtbLlU0Y1R3QoBnT0aB4qv/BEiVVsj7LJXoQCgJ2vA==", "dev": true }, "node_modules/@sideway/address": { @@ -1000,9 +1000,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.18.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.11.tgz", - "integrity": "sha512-c1vku6qnTeujJneYH94/4aq73XrVcsJe35UPyAsSok1ijiKrkRzK+AxQPSpNMUnC03roWBBwJx/9I8V7lQoxmA==", + "version": "18.18.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.12.tgz", + "integrity": "sha512-G7slVfkwOm7g8VqcEF1/5SXiMjP3Tbt+pXDU3r/qhlM2KkGm786DUD4xyMA2QzEElFrv/KZV9gjygv4LnkpbMQ==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -1027,9 +1027,9 @@ "dev": true }, "node_modules/@types/sizzle": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.7.tgz", - "integrity": "sha512-sU5MNKvSFdbT97qLSabU6jxceY9BfYQe9uF+b8E1rdTecpq9ROkkKoiHlblUlhgfaz9bdCByWjAI40Y3mHf1iQ==", + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.8.tgz", + "integrity": "sha512-0vWLNK2D5MT9dg0iOo8GlKguPAU02QjmZitPEsXRuJXU/OGIOt9vT9Fc26wtYuavLxtO45v9PGleoL9Z0k1LHg==", "dev": true }, "node_modules/@types/web-bluetooth": { @@ -2261,9 +2261,9 @@ "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, "node_modules/cypress": { - "version": "13.5.1", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.5.1.tgz", - "integrity": "sha512-yqLViT0D/lPI8Kkm7ciF/x/DCK/H/DnogdGyiTnQgX4OVR2aM30PtK+kvklTOD1u3TuItiD9wUQAF8EYWtyZug==", + "version": "13.6.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.6.0.tgz", + "integrity": "sha512-quIsnFmtj4dBUEJYU4OH0H12bABJpSujvWexC24Ju1gTlKMJbeT6tTO0vh7WNfiBPPjoIXLN+OUqVtiKFs6SGw==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -4136,9 +4136,9 @@ } }, "node_modules/lru-cache": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.3.tgz", - "integrity": "sha512-B7gr+F6MkqB3uzINHXNctGieGsRTMwIBgxkp0yq/5BwcuDzD4A8wQpHQW6vDAm1uKSLQghmRdD9sKqf2vJ1cEg==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz", + "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==", "dev": true, "engines": { "node": "14 || >=16.14" @@ -4845,9 +4845,9 @@ "integrity": "sha512-KDeO94CbWI4pKsPnYpA1FPjo79EsY9I+M8ywoPBSf9XMXoe/0crjbUK7jcQEDHuc0ZMRIZsxH3TYLv4TUtHmAA==" }, "node_modules/primevue": { - "version": "3.41.0", - "resolved": "https://registry.npmjs.org/primevue/-/primevue-3.41.0.tgz", - "integrity": "sha512-xdoB5JtAmam/05f2AbVdYA26XhHgeZZ4w+crQ5FZAeq3CkFL5tWjreWLwbtUWYhWimhdk9ZCrCvX/L+FjuWR/Q==", + "version": "3.41.1", + "resolved": "https://registry.npmjs.org/primevue/-/primevue-3.41.1.tgz", + "integrity": "sha512-+RDGLsw7ktS2Jz/mptPwwbW/YI5E0u1tWYustlG745FFdX3o1/Dxs47hdnvo22wysPUQr1mdh/uznsKJZMV7fw==", "peerDependencies": { "vue": "^3.0.0" } @@ -5965,12 +5965,12 @@ } }, "node_modules/vue-i18n": { - "version": "9.7.0", - "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.7.0.tgz", - "integrity": "sha512-8Z8kSz9U2juzuAf+6mjW1HTd5pIlYuFJZkC+HvYOglFdpzwc2rTUGjxKwN8xGdtGur1MFnyJ44TSr+TksJtY8A==", + "version": "9.7.1", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.7.1.tgz", + "integrity": "sha512-A6DzWqJQMdzBj+392+g3zIgGV0FnFC7o/V+txs5yIALANEZzY6ZV8hM2wvZR3nTbQI7dntAmzBHMeoEteJO0kQ==", "dependencies": { - "@intlify/core-base": "9.7.0", - "@intlify/shared": "9.7.0", + "@intlify/core-base": "9.7.1", + "@intlify/shared": "9.7.1", "@vue/devtools-api": "^6.5.0" }, "engines": { @@ -6053,9 +6053,9 @@ } }, "node_modules/webpack-virtual-modules": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.0.tgz", - "integrity": "sha512-KnaMTE6EItz/f2q4Gwg5/rmeKVi79OR58NoYnwDJqCk9ywMtTGbBnBcfoBtN4QbYu0lWXvyMoH2Owxuhe4qI6Q==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.1.tgz", + "integrity": "sha512-poXpCylU7ExuvZK8z+On3kX+S8o/2dQ/SVYueKA0D4WEMXROXgY8Ez50/bQEUmvoSMMrWcrJqCHuhAbsiwg7Dg==", "dev": true }, "node_modules/which": { diff --git a/frontend/src/assets/primefaces/theme-base/components/menu/_menubar.scss b/frontend/src/assets/primefaces/theme-base/components/menu/_menubar.scss index b5c8d215..7562ab44 100644 --- a/frontend/src/assets/primefaces/theme-base/components/menu/_menubar.scss +++ b/frontend/src/assets/primefaces/theme-base/components/menu/_menubar.scss @@ -35,7 +35,7 @@ } } -@media screen and (max-width: 960px) { +@media screen and (max-width: 320px) { .p-menubar { position: relative; diff --git a/frontend/src/assets/primefaces/themes/ablegram/_extensions.scss b/frontend/src/assets/primefaces/themes/ablegram/_extensions.scss index a07d6700..91be71ae 100644 --- a/frontend/src/assets/primefaces/themes/ablegram/_extensions.scss +++ b/frontend/src/assets/primefaces/themes/ablegram/_extensions.scss @@ -122,3 +122,9 @@ box-shadow $transitionDuration; } } + +/* fix background for Menubar and MegaMenu in mobile view */ +.p-menubar-root-list, +.p-megamenu-panel { + background-color: white; +} diff --git a/frontend/src/components/auth/LoginWithPasswordForm.vue b/frontend/src/components/auth/LoginWithPasswordForm.vue new file mode 100644 index 00000000..73401072 --- /dev/null +++ b/frontend/src/components/auth/LoginWithPasswordForm.vue @@ -0,0 +1,66 @@ + + + diff --git a/frontend/src/components/auth/UserAvatar.vue b/frontend/src/components/auth/UserAvatar.vue new file mode 100644 index 00000000..1eb9d110 --- /dev/null +++ b/frontend/src/components/auth/UserAvatar.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/frontend/src/components/parts/MenuBar.vue b/frontend/src/components/parts/MenuBar.vue index 94b3c258..cf96fd0b 100644 --- a/frontend/src/components/parts/MenuBar.vue +++ b/frontend/src/components/parts/MenuBar.vue @@ -1,5 +1,5 @@ diff --git a/frontend/src/layouts/AppLayout.vue b/frontend/src/layouts/AppLayout.vue index af3494fd..b975a4f2 100644 --- a/frontend/src/layouts/AppLayout.vue +++ b/frontend/src/layouts/AppLayout.vue @@ -5,7 +5,7 @@

Ablegram

- @@ -30,6 +32,7 @@ import MenuBar from '@/components/parts/MenuBar.vue' import ProgressLogo from '@/components/parts/ProgressLogo.vue' import DynamicDialog from 'primevue/dynamicdialog' import ConfirmDialog from 'primevue/confirmdialog' +import UserAvatar from '@/components/auth/UserAvatar.vue'