From d3f9faaf2d3e171704458a0b21d0c3bd8e2ab91a Mon Sep 17 00:00:00 2001 From: Mo Mansour Date: Tue, 1 Oct 2024 15:56:21 +0300 Subject: [PATCH 1/4] chore: upgrade nuxt-auth and its config (#238) --- nuxt.config.ts | 18 ++++++++---------- package-lock.json | 21 +++++++++++++-------- package.json | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index a882257..94ad0f2 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -63,6 +63,7 @@ export default defineNuxtConfig({ // Keys within public, will be also exposed to the client-side public: { communityApiUrl: '', + authBaseUrl: '', targetEnv: '', buildCommitSha: '', buildCommitLink: '', @@ -87,25 +88,22 @@ export default defineNuxtConfig({ }, auth: { - baseURL: process.env.NUXT_PUBLIC_AUTH_BASE_URL || '', + originEnvKey: 'NUXT_PUBLIC_AUTH_BASE_URL', + baseURL: process.env.NUXT_PUBLIC_AUTH_BASE_URL ?? '', provider: { type: 'local', endpoints: { - signIn: { path: '/login', method: 'post' }, - signOut: { path: '/logout', method: 'get' }, - getSession: { path: '/', method: 'get' }, + signIn: { path: 'login', method: 'post' }, + signOut: { path: 'logout', method: 'get' }, + getSession: { path: '', method: 'get' }, }, token: { signInResponseTokenPointer: '/access_token', cookieName: 'access_token', type: 'Bearer', maxAgeInSeconds: 60 * 60 * 24, - }, - sessionDataType: { - id: 'string', - username: 'string', - iat: 'number', - exp: 'number', + secureCookieAttribute: true, + httpOnlyCookieAttribute: true, // NOTE: disable in local development }, }, }, diff --git a/package-lock.json b/package-lock.json index 63d24ae..b749fb0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@kevinmarrec/nuxt-pwa": "^0.17.0", "@nuxtjs/sitemap": "^6.0.1", "@nuxtjs/tailwindcss": "^6.12.1", - "@sidebase/nuxt-auth": "^0.7.2", + "@sidebase/nuxt-auth": "^0.9.3", "@volar-plugins/vetur": "latest", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", @@ -2681,18 +2681,23 @@ ] }, "node_modules/@sidebase/nuxt-auth": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/@sidebase/nuxt-auth/-/nuxt-auth-0.7.2.tgz", - "integrity": "sha512-0f/DxRvDKFBwg5jR85KMeuVGQSygnDl3LOFeXnEHOS3A9SnJLE8najNooq7DbQB6lB8dl+vDpguVNH+V92TiHg==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@sidebase/nuxt-auth/-/nuxt-auth-0.9.3.tgz", + "integrity": "sha512-celbFy5j1IIFUpVQA+0CvqzxqFTdHS3SFMHnPGONzrjka0BDIDOHtMfZ7xyIgOb8OaBdibjRsqeUhhJmBYfkOA==", "dev": true, "dependencies": { - "@nuxt/kit": "^3.11.2", + "@nuxt/kit": "^3.12.4", "defu": "^6.1.4", - "h3": "^1.11.1", + "h3": "^1.12.0", "knitwork": "^1.1.0", - "nitropack": "^2.9.6", + "nitropack": "^2.9.7", "requrl": "^3.0.2", - "ufo": "^1.5.3" + "scule": "^1.3.0", + "ufo": "^1.5.4" + }, + "engines": { + "node": ">=20", + "pnpm": ">=9.4.0" }, "peerDependencies": { "next-auth": "~4.21.1" diff --git a/package.json b/package.json index cc587e0..bb795e6 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "@kevinmarrec/nuxt-pwa": "^0.17.0", "@nuxtjs/sitemap": "^6.0.1", "@nuxtjs/tailwindcss": "^6.12.1", - "@sidebase/nuxt-auth": "^0.7.2", + "@sidebase/nuxt-auth": "^0.9.3", "@volar-plugins/vetur": "latest", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", From 93458f94af6cad7e1297af15de89bbe778264c4f Mon Sep 17 00:00:00 2001 From: Mohamed Mansour Date: Thu, 3 Oct 2024 15:29:23 +0300 Subject: [PATCH 2/4] build(.drone.yml): pass auth url --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 7d0bc2c..db5cdeb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,4 +5,4 @@ load: container.jsonnet data: repositoryName: josaorg/community-web releaseName: community-web - buildArgs: + buildArgs: NUXT_PUBLIC_AUTH_BASE_URL=https://community.api.prod.josa.ngo/v2/auth/ From fe1a9ceaa1855c19dd1c6c4792a88dc224d235f4 Mon Sep 17 00:00:00 2001 From: Mohamed Mansour Date: Thu, 3 Oct 2024 16:43:09 +0300 Subject: [PATCH 3/4] build(nuxt.config.ts): hardcode the auth url as a temporary solution --- nuxt.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 94ad0f2..61537cb 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -89,7 +89,7 @@ export default defineNuxtConfig({ auth: { originEnvKey: 'NUXT_PUBLIC_AUTH_BASE_URL', - baseURL: process.env.NUXT_PUBLIC_AUTH_BASE_URL ?? '', + baseURL: 'https://community.api.prod.josa.ngo/v2/auth/', provider: { type: 'local', endpoints: { From 23d087a236f7bc95e8afbdc0b471cc769e257bc9 Mon Sep 17 00:00:00 2001 From: Mohamed Mansour Date: Thu, 3 Oct 2024 16:44:03 +0300 Subject: [PATCH 4/4] build(nuxt.config.ts): set auth session data types --- nuxt.config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nuxt.config.ts b/nuxt.config.ts index 61537cb..4d82c34 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -105,6 +105,14 @@ export default defineNuxtConfig({ secureCookieAttribute: true, httpOnlyCookieAttribute: true, // NOTE: disable in local development }, + session: { + dataType: { + id: 'string', + username: 'string', + iat: 'number', + exp: 'number', + }, + }, }, },