Add UUID to each oidc config to distinguish each provider

This commit is contained in:
Peter Clement 2021-07-13 15:52:21 +01:00
parent af792cc09e
commit 9dd05ec96e
5 changed files with 29 additions and 11 deletions

View File

@ -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,
}

View File

@ -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">

View File

@ -4,6 +4,7 @@ import api from "builderStore/api"
const OIDC_CONFIG = {
logo: undefined,
name: undefined,
uuid: undefined,
}
export function createOidcStore() {

View File

@ -113,6 +113,7 @@ exports.publicOidc = async function (ctx) {
return {
logo: config.logo,
name: config.name,
uuid: config.uuid,
}
})
ctx.body = partialOidcCofig

View File

@ -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)