Merge pull request #2770 from Budibase/fix/logout

Set cookie domain to fix logout
This commit is contained in:
Rory Powell 2021-09-28 16:54:17 +01:00 committed by GitHub
commit 79bfe7fc1b
6 changed files with 16 additions and 2 deletions

View File

@ -94,6 +94,8 @@ spec:
value: {{ .Values.globals.sentryDSN }}
- name: WORKER_URL
value: worker-service:{{ .Values.services.worker.port }}
- name: COOKIE_DOMAIN
value: {{ .Values.globals.cookieDomain | quote }}
image: budibase/apps
imagePullPolicy: Always
name: bbapps

View File

@ -89,6 +89,8 @@ spec:
value: {{ .Values.globals.selfHosted | quote }}
- name: ACCOUNT_PORTAL_URL
value: {{ .Values.globals.accountPortalUrl | quote }}
- name: COOKIE_DOMAIN
value: {{ .Values.globals.cookieDomain | quote }}
image: budibase/worker
imagePullPolicy: Always
name: bbworker

View File

@ -90,6 +90,7 @@ globals:
logLevel: info
selfHosted: 1
accountPortalUrL: ""
cookieDomain: ""
createSecrets: true # creates an internal API key, JWT secrets and redis password for you
# if createSecrets is set to false, you can hard-code your secrets here

View File

@ -22,6 +22,7 @@ module.exports = {
MULTI_TENANCY: process.env.MULTI_TENANCY,
ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED),
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
isTest,
_set(key, value) {
process.env[key] = value

View File

@ -4,6 +4,7 @@ const { options } = require("./middleware/passport/jwt")
const { createUserEmailView } = require("./db/views")
const { Headers } = require("./constants")
const { getGlobalDB } = require("./tenancy")
const environment = require("./environment")
const APP_PREFIX = DocumentTypes.APP + SEPARATOR
@ -70,12 +71,19 @@ exports.setCookie = (ctx, value, name = "builder") => {
ctx.cookies.set(name)
} else {
value = jwt.sign(value, options.secretOrKey)
ctx.cookies.set(name, value, {
const config = {
maxAge: Number.MAX_SAFE_INTEGER,
path: "/",
httpOnly: false,
overwrite: true,
})
}
if (environment.COOKIE_DOMAIN) {
config.domain = environment.COOKIE_DOMAIN
}
ctx.cookies.set(name, value, config)
}
}