From b706333c85f6dda766335f9248f49fb517b2e8be Mon Sep 17 00:00:00 2001 From: les Date: Mon, 27 Jan 2020 00:47:03 +0100 Subject: [PATCH] use oauth2 password flow for webclient --- components/Nav.vue | 1 + components/admin/Settings.vue | 2 +- nuxt.config.js | 18 +- package.json | 14 +- pages/Login.vue | 15 +- pages/event/followMe.vue | 36 ++-- pages/settings.vue | 10 +- server/api/auth.js | 45 ++--- server/api/controller/event.js | 345 +++++++++++++++------------------ server/api/controller/oauth.js | 27 ++- server/api/controller/user.js | 29 --- server/api/index.js | 41 ++-- server/api/mail.js | 2 +- server/api/oauth.js | 4 + server/federation/helpers.js | 30 +-- server/federation/index.js | 6 + server/helpers.js | 28 +-- server/notifier.js | 2 +- server/routes.js | 22 ++- store/index.js | 24 +-- yarn.lock | 114 +++++------ 21 files changed, 367 insertions(+), 448 deletions(-) diff --git a/components/Nav.vue b/components/Nav.vue index f48f6a22..8084d3f5 100644 --- a/components/Nav.vue +++ b/components/Nav.vue @@ -18,6 +18,7 @@ el-menu-item(v-if='!$auth.loggedIn' index='/login') i.el-icon-user span.hidden-xs-only {{$t('common.login')}} + el-submenu(v-if='$auth.loggedIn' index=3) template(slot='title') i.el-icon-user diff --git a/components/admin/Settings.vue b/components/admin/Settings.vue index f5a348c1..f1b998db 100644 --- a/components/admin/Settings.vue +++ b/components/admin/Settings.vue @@ -48,7 +48,7 @@ export default { data ({ $store }) { return { title: $store.state.settings.title, - description: $store.state.settings.description, + description: $store.state.settings.description } }, computed: { diff --git a/nuxt.config.js b/nuxt.config.js index f55df5f8..3927469a 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -67,15 +67,27 @@ module.exports = { prefix: '/api' }, auth: { + // localStorage: false, // https://github.com/nuxt-community/auth-module/issues/425 + cookie: { + prefix: 'auth.', + expires: 360, + maxAge: 60 * 60 * 24 * 30 + }, redirect: { - login: '/login' + login: '../login' }, strategies: { local: { endpoints: { - login: { url: '/auth/login', method: 'post', propertyName: 'token' }, + login: { + url: '../oauth/login', + method: 'post', + propertyName: 'access_token', + withCredentials: true, + headers: { 'Content-Type': 'application/x-www-form-urlencoded' } + }, logout: false, - user: { url: '/auth/user', method: 'get', propertyName: false } + user: { url: '/user', method: 'get', propertyName: false } }, tokenRequired: true, tokenType: 'Bearer' diff --git a/package.json b/package.json index d9116c9a..9f3a9c4e 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@nuxtjs/auth": "^4.8.5", "@nuxtjs/axios": "^5.9.3", "accept-language": "^3.0.18", - "axios": "^0.19.1", + "axios": "^0.19.2", "bcryptjs": "^2.4.3", "body-parser": "^1.18.3", "bootstrap": "^4.4.1", @@ -64,26 +64,22 @@ "consola": "^2.11.3", "cookie-parser": "^1.4.4", "cors": "^2.8.5", - "cross-env": "^6.0.0", + "cross-env": "^7.0.0", "dayjs": "^1.8.19", "element-ui": "^2.13.0", - "email-templates": "^7.0.1", + "email-templates": "^7.0.2", "express": "^4.17.1", - "express-jwt": "^5.3.1", - "express-middleware-log": "^1.2.0", "express-oauth-server": "^2.0.0", "http-signature": "^1.3.1", "ics": "^2.16.0", - "inquirer": "^7.0.3", + "inquirer": "^7.0.4", "jsonwebtoken": "^8.5.1", "less": "^3.10.3", "lodash": "^4.17.14", - "mkdirp": "^0.5.1", - "modern-css-reset": "^1.0.4", + "mkdirp": "^1.0.3", "moment-timezone": "^0.5.27", "morgan": "^1.9.1", "multer": "^1.4.2", - "node-fetch": "^2.6.0", "nuxt": "^2.11.0", "nuxt-express-module": "^0.0.11", "pg": "^7.17.1", diff --git a/pages/Login.vue b/pages/Login.vue index 0bc1d1ff..a6aecf5f 100644 --- a/pages/Login.vue +++ b/pages/Login.vue @@ -22,7 +22,7 @@ @@ -60,4 +58,4 @@ export default { .instance_thumb { height: 20px; } - \ No newline at end of file + diff --git a/pages/settings.vue b/pages/settings.vue index c8457fa6..e754d27d 100644 --- a/pages/settings.vue +++ b/pages/settings.vue @@ -13,19 +13,11 @@