Browse Source

Merge pull request #2898 from Budibase/fix/custom-sso-redirect

Updates to suport non cloud single and multi tenancy
gh-pages
Martin McKeaveney 5 years ago
committed by GitHub
parent
commit
1c9147974e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      hosting/kubernetes/budibase/templates/app-service-deployment.yaml
  2. 30
      packages/builder/src/pages/builder/_layout.svelte

4
hosting/kubernetes/budibase/templates/app-service-deployment.yaml

@ -96,6 +96,10 @@ spec:
value: worker-service:{{ .Values.services.worker.port }} value: worker-service:{{ .Values.services.worker.port }}
- name: COOKIE_DOMAIN - name: COOKIE_DOMAIN
value: {{ .Values.globals.cookieDomain | quote }} value: {{ .Values.globals.cookieDomain | quote }}
- name: ACCOUNT_PORTAL_URL
value: {{ .Values.globals.accountPortalUrl | quote }}
- name: ACCOUNT_PORTAL_API_KEY
value: {{ .Values.globals.accountPortalApiKey | quote }}
image: budibase/apps image: budibase/apps
imagePullPolicy: Always imagePullPolicy: Always
name: bbapps name: bbapps

30
packages/builder/src/pages/builder/_layout.svelte

@ -20,25 +20,29 @@
return return
} }
if (user && user.tenantId) { // e.g. ['tenant', 'budibase', 'app'] vs ['budibase', 'app']
let urlTenantId let urlTenantId
const hostParts = host.split(".") const hostParts = host.split(".")
if (hostParts.length > 2) {
urlTenantId = hostParts[0]
}
// only run validation when we know we are in a tenant url // no tenant in the url - send to account portal to fix this
// not when we visit the root budibase.app domain if (!urlTenantId) {
// e.g. ['tenant', 'budibase', 'app'] vs ['budibase', 'app'] window.location.href = $admin.accountPortalUrl
if (hostParts.length > 2) { return
urlTenantId = hostParts[0] }
} else {
// no tenant in the url - send to account portal to fix this
window.location.href = $admin.accountPortalUrl
return
}
if (user && user.tenantId) {
if (user.tenantId !== urlTenantId) { if (user.tenantId !== urlTenantId) {
// user should not be here - play it safe and log them out // user should not be here - play it safe and log them out
await auth.logout() await auth.logout()
await auth.setOrganisation(null)
return
} }
} else {
// no user - set the org according to the url
await auth.setOrganisation(urlTenantId)
} }
} }

Loading…
Cancel
Save