Linting and adding tenancy API.
This commit is contained in:
parent
e98965a805
commit
e3744c0b20
|
@ -1,9 +1,9 @@
|
|||
<script>
|
||||
import { ActionButton } from "@budibase/bbui"
|
||||
import GoogleLogo from "assets/google-logo.png"
|
||||
import { admin, auth, organisation } from "stores/portal"
|
||||
import { auth, organisation } from "stores/portal"
|
||||
|
||||
let show = false
|
||||
let show
|
||||
|
||||
$: tenantId = $auth.tenantId
|
||||
$: show = $organisation.google
|
||||
|
|
|
@ -33,18 +33,28 @@
|
|||
|
||||
$: GoogleConfigFields = {
|
||||
Google: [
|
||||
{name: "clientID", label: "Client ID"},
|
||||
{name: "clientSecret", label: "Client secret"},
|
||||
{name: "callbackURL", label: "Callback URL", readonly: true, placeholder: `/api/admin/auth/${tenantId}/google/callback`},
|
||||
{ name: "clientID", label: "Client ID" },
|
||||
{ name: "clientSecret", label: "Client secret" },
|
||||
{
|
||||
name: "callbackURL",
|
||||
label: "Callback URL",
|
||||
readonly: true,
|
||||
placeholder: `/api/admin/auth/${tenantId}/google/callback`,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
$: OIDCConfigFields = {
|
||||
Oidc: [
|
||||
{name: "configUrl", label: "Config URL"},
|
||||
{name: "clientID", label: "Client ID"},
|
||||
{name: "clientSecret", label: "Client Secret"},
|
||||
{name: "callbackURL", label: "Callback URL", readonly: true, placeholder: `/api/admin/auth/${tenantId}/oidc/callback`},
|
||||
{ name: "configUrl", label: "Config URL" },
|
||||
{ name: "clientID", label: "Client ID" },
|
||||
{ name: "clientSecret", label: "Client Secret" },
|
||||
{
|
||||
name: "callbackURL",
|
||||
label: "Callback URL",
|
||||
readonly: true,
|
||||
placeholder: `/api/admin/auth/${tenantId}/oidc/callback`,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -286,7 +296,11 @@
|
|||
{#each GoogleConfigFields.Google as field}
|
||||
<div class="form-row">
|
||||
<Label size="L">{field.label}</Label>
|
||||
<Input bind:value={providers.google.config[field.name]} readonly={field.readonly} placeholder={field.placeholder} />
|
||||
<Input
|
||||
bind:value={providers.google.config[field.name]}
|
||||
readonly={field.readonly}
|
||||
placeholder={field.placeholder}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
<div class="form-row">
|
||||
|
@ -326,7 +340,11 @@
|
|||
{#each OIDCConfigFields.Oidc as field}
|
||||
<div class="form-row">
|
||||
<Label size="L">{field.label}</Label>
|
||||
<Input bind:value={providers.oidc.config.configs[0][field.name]} readonly={field.readonly} placeholder={field.placeholder} />
|
||||
<Input
|
||||
bind:value={providers.oidc.config.configs[0][field.name]}
|
||||
readonly={field.readonly}
|
||||
placeholder={field.placeholder}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
<br />
|
||||
|
|
|
@ -22,12 +22,13 @@ export function createAdminStore() {
|
|||
|
||||
admin.update(store => {
|
||||
store.checklist = json
|
||||
store.onboardingProgress = (stepsComplete / onboardingSteps.length) * 100
|
||||
store.onboardingProgress =
|
||||
(stepsComplete / onboardingSteps.length) * 100
|
||||
return store
|
||||
})
|
||||
await multiTenancyEnabled()
|
||||
} catch (err) {
|
||||
admin.update( store => {
|
||||
admin.update(store => {
|
||||
store.checklist = null
|
||||
return store
|
||||
})
|
||||
|
|
|
@ -14,7 +14,9 @@ export function createOidcStore() {
|
|||
|
||||
async function init() {
|
||||
const tenantId = get(auth).tenantId
|
||||
const res = await api.get(`/api/admin/configs/public/oidc?tenantId=${tenantId}`)
|
||||
const res = await api.get(
|
||||
`/api/admin/configs/public/oidc?tenantId=${tenantId}`
|
||||
)
|
||||
const json = await res.json()
|
||||
|
||||
if (json.status === 400 || Object.keys(json).length === 0) {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
const env = require("../../../environment")
|
||||
const CouchDB = require("../../../db")
|
||||
const { StaticDatabases } = require("@budibase/auth/db")
|
||||
|
||||
exports.multiTenancyEnabled = async ctx => {
|
||||
ctx.body = {
|
||||
|
@ -7,9 +9,32 @@ exports.multiTenancyEnabled = async ctx => {
|
|||
}
|
||||
|
||||
exports.exists = async ctx => {
|
||||
|
||||
const tenantId = ctx.request.params
|
||||
const db = new CouchDB(StaticDatabases.PLATFORM_INFO.name)
|
||||
let exists = false
|
||||
try {
|
||||
const tenantsDoc = await db.get(StaticDatabases.PLATFORM_INFO.docs.tenants)
|
||||
if (tenantsDoc) {
|
||||
exists = tenantsDoc.tenantIds.indexOf(tenantId) !== -1
|
||||
}
|
||||
} catch (err) {
|
||||
// if error it doesn't exist
|
||||
}
|
||||
ctx.body = {
|
||||
exists,
|
||||
}
|
||||
}
|
||||
|
||||
exports.fetch = async ctx => {
|
||||
|
||||
const db = new CouchDB(StaticDatabases.PLATFORM_INFO.name)
|
||||
let tenants = []
|
||||
try {
|
||||
const tenantsDoc = await db.get(StaticDatabases.PLATFORM_INFO.docs.tenants)
|
||||
if (tenantsDoc) {
|
||||
tenants = tenantsDoc.tenantIds
|
||||
}
|
||||
} catch (err) {
|
||||
// if error it doesn't exist
|
||||
}
|
||||
ctx.body = tenants
|
||||
}
|
||||
|
|
|
@ -45,7 +45,11 @@ async function doesTenantExist(tenantId) {
|
|||
// if theres an error the doc doesn't exist, no tenants exist
|
||||
return false
|
||||
}
|
||||
return tenants && Array.isArray(tenants.tenantIds) && tenants.tenantIds.indexOf(tenantId) !== -1
|
||||
return (
|
||||
tenants &&
|
||||
Array.isArray(tenants.tenantIds) &&
|
||||
tenants.tenantIds.indexOf(tenantId) !== -1
|
||||
)
|
||||
}
|
||||
|
||||
async function allUsers(ctx) {
|
||||
|
|
|
@ -47,7 +47,10 @@ router
|
|||
.post("/api/admin/auth/logout", authController.logout)
|
||||
.get("/api/admin/auth/:tenantId/google", authController.googlePreAuth)
|
||||
.get("/api/admin/auth/:tenantId/google/callback", authController.googleAuth)
|
||||
.get("/api/admin/auth/:tenantId/oidc/configs/:configId", authController.oidcPreAuth)
|
||||
.get(
|
||||
"/api/admin/auth/:tenantId/oidc/configs/:configId",
|
||||
authController.oidcPreAuth
|
||||
)
|
||||
.get("/api/admin/auth/:tenantId/oidc/callback", authController.oidcAuth)
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -9,4 +9,4 @@ router
|
|||
.get("/api/admin/tenants/:tenantId/exists", controller.exists)
|
||||
.get("/api/admin/tenants", adminOnly, controller.fetch)
|
||||
|
||||
module.exports = router
|
||||
module.exports = router
|
||||
|
|
Loading…
Reference in New Issue