This commit is contained in:
Andras Bacsai 2022-10-14 15:54:19 +02:00
parent 462eea90c0
commit a7e86d9afd
2 changed files with 14 additions and 11 deletions

View File

@ -111,19 +111,21 @@ export default [
{
"id": "$$secret_name",
"label": "Admin Name",
"defaultValue": "admin",
"defaultValue": "$$generate_username",
"description": "This is the admin username. Please change it.",
"validRegex": /^([^\s^\/])+$/
},
{
"id": "$$secret_password",
"label": "Admin Password",
"defaultValue":"$$generate_password",
"description": "This is the admin password. Please change it.",
"validRegex": /^([^\s^\/])+$/
},
{
"id": "$$secret_secret_key_base",
"label": "Secret Key Base",
"defaultValue":"$$generate_passphrase",
"description": "",
"validRegex": /^([^\s^\/])+$/
},
@ -141,13 +143,6 @@ export default [
"description": "",
"validRegex": /^([^\s^\/])+$/
},
{
"id": "$$secret_disable_registration",
"label": "Disable Registration",
"defaultValue": "true",
"description": "",
"validRegex": /^([^\s^\/])+$/
},
{
"id": "$$secret_postgresql_username",
"label": "PostgreSQL Username",
@ -158,7 +153,7 @@ export default [
{
"id": "$$secret_postgresql_password",
"label": "PostgreSQL Password",
"defaultValue": "postgresql",
"defaultValue": "$$generate_password",
"description": "",
"validRegex": /^([^\s^\/])+$/
}

View File

@ -157,9 +157,17 @@ export async function saveServiceType(request: FastifyRequest<SaveServiceType>,
if (variableId.startsWith('$$secret_')) {
const secretName = variableId.replace('$$secret_', '');
let secretValue = defaultValue || value || null;
if (secretValue) secretValue = encrypt(secretValue);
if (defaultValue === '$$generate_password') {
secretValue = generatePassword({});
}
if (defaultValue === '$$generate_username') {
secretValue = cuid();
}
if (defaultValue === '$$generate_passphrase') {
secretValue = cuid();
}
await prisma.serviceSecret.create({
data: { name: secretName, value: secretValue, service: { connect: { id } } }
data: { name: secretName, value: encrypt(secretValue), service: { connect: { id } } }
})
}
}