Add UUID to each oidc config to distinguish each provider
This commit is contained in:
parent
af792cc09e
commit
9dd05ec96e
|
@ -7,14 +7,21 @@ const mockEmail = "mock@budibase.com"
|
|||
const mockAccessToken = "mockAccessToken"
|
||||
const mockRefreshToken = "mockRefreshToken"
|
||||
|
||||
const buildOauth2 = (accessToken=mockAccessToken, refreshToken=mockRefreshToken) => (
|
||||
{
|
||||
accessToken: accessToken,
|
||||
refreshToken: refreshToken,
|
||||
}
|
||||
)
|
||||
const buildOauth2 = (
|
||||
accessToken = mockAccessToken,
|
||||
refreshToken = mockRefreshToken
|
||||
) => ({
|
||||
accessToken: accessToken,
|
||||
refreshToken: refreshToken,
|
||||
})
|
||||
|
||||
const buildThirdPartyUser = (provider, providerType, profile, email=mockEmail, oauth2=buildOauth2()) => ({
|
||||
const buildThirdPartyUser = (
|
||||
provider,
|
||||
providerType,
|
||||
profile,
|
||||
email = mockEmail,
|
||||
oauth2 = buildOauth2()
|
||||
) => ({
|
||||
provider: provider,
|
||||
providerType: providerType,
|
||||
userId: profile.id,
|
||||
|
@ -29,5 +36,5 @@ exports.data = {
|
|||
email: mockEmail,
|
||||
accessToken: mockAccessToken,
|
||||
refreshToken: mockRefreshToken,
|
||||
buildThirdPartyUser
|
||||
}
|
||||
buildThirdPartyUser,
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
import { onMount } from "svelte"
|
||||
import api from "builderStore/api"
|
||||
import { organisation } from "stores/portal"
|
||||
import { uuid } from "builderStore/uuid"
|
||||
|
||||
const ConfigTypes = {
|
||||
Google: "google",
|
||||
|
@ -87,10 +88,17 @@
|
|||
const providers = { google, oidc }
|
||||
|
||||
async function save(docs) {
|
||||
console.log(docs)
|
||||
// only if the user has provided an image, upload it.
|
||||
image && uploadLogo(image)
|
||||
let calls = []
|
||||
docs.forEach(element => {
|
||||
//Add a UUID here so each config is distinguishable when it arrives at the login page.
|
||||
if (element.type === "oidc") {
|
||||
element.config.configs.forEach(config => {
|
||||
config.uuid = uuid()
|
||||
})
|
||||
}
|
||||
calls.push(api.post(`/api/admin/configs`, element))
|
||||
})
|
||||
Promise.all(calls)
|
||||
|
@ -184,7 +192,7 @@
|
|||
To allow users to authenticate using their Google accounts, fill out the
|
||||
fields below.
|
||||
</Body>
|
||||
</Layout>dddd
|
||||
</Layout>
|
||||
<Layout gap="XS" noPadding>
|
||||
{#each GoogleConfigFields.Google as field}
|
||||
<div class="form-row">
|
||||
|
|
|
@ -4,6 +4,7 @@ import api from "builderStore/api"
|
|||
const OIDC_CONFIG = {
|
||||
logo: undefined,
|
||||
name: undefined,
|
||||
uuid: undefined,
|
||||
}
|
||||
|
||||
export function createOidcStore() {
|
||||
|
|
|
@ -113,6 +113,7 @@ exports.publicOidc = async function (ctx) {
|
|||
return {
|
||||
logo: config.logo,
|
||||
name: config.name,
|
||||
uuid: config.uuid,
|
||||
}
|
||||
})
|
||||
ctx.body = partialOidcCofig
|
||||
|
|
|
@ -50,7 +50,8 @@ function oidcValidation() {
|
|||
clientSecret: Joi.string().required(),
|
||||
configUrl: Joi.string().required(),
|
||||
logo: Joi.string().optional(),
|
||||
name: Joi.string().optional(),
|
||||
name: Joi.string().optional(),
|
||||
uuid: Joi.string().required(),
|
||||
})
|
||||
).required(true)
|
||||
}).unknown(true)
|
||||
|
|
Loading…
Reference in New Issue