1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00

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 ca0f74eee8
commit 2900743545
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)