feat: add ability to configure application with a config file (#740)
* add config file possibility * revert port in docker compose * Update docker-compose.yml Co-authored-by: Elias Schneider <login@eliasschneider.com> * Update docker-compose.yml Co-authored-by: Elias Schneider <login@eliasschneider.com> * add attribute description to config file * remove email message config * add package to resolve errors * remove email messages from config * move config initialization to config module * revert unnecessary change * add order * improve alert * run formatter * remove unnecessary packages * remove unnecessary types * use logger * don't save yaml config to db * allowEdit if no yaml config is set * improve docs * fix allow edit state * remove unnecessary check and refactor code * restore old config file * add script that generates `config.example.yaml` automatically * allow config variables to be changed if they are not set in the `config.yml` * add back init user * Revert "allow config variables to be changed if they are not set in the `config.yml`" This reverts commit 7dbdb6729034be5b083f126f854d5e1411735a54. * improve info box text --------- Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Prisma, PrismaClient } from "@prisma/client";
|
||||
import * as crypto from "crypto";
|
||||
|
||||
const configVariables: ConfigVariables = {
|
||||
export const configVariables = {
|
||||
internal: {
|
||||
jwtSecret: {
|
||||
type: "string",
|
||||
@@ -181,12 +181,12 @@ const configVariables: ConfigVariables = {
|
||||
},
|
||||
searchQuery: {
|
||||
type: "string",
|
||||
defaultValue: ""
|
||||
defaultValue: "",
|
||||
},
|
||||
|
||||
adminGroups: {
|
||||
type: "string",
|
||||
defaultValue: ""
|
||||
defaultValue: "",
|
||||
},
|
||||
|
||||
fieldNameMemberOf: {
|
||||
@@ -196,18 +196,18 @@ const configVariables: ConfigVariables = {
|
||||
fieldNameEmail: {
|
||||
type: "string",
|
||||
defaultValue: "userPrincipalName",
|
||||
}
|
||||
},
|
||||
},
|
||||
oauth: {
|
||||
"allowRegistration": {
|
||||
allowRegistration: {
|
||||
type: "boolean",
|
||||
defaultValue: "true",
|
||||
},
|
||||
"ignoreTotp": {
|
||||
ignoreTotp: {
|
||||
type: "boolean",
|
||||
defaultValue: "true",
|
||||
},
|
||||
"disablePassword": {
|
||||
disablePassword: {
|
||||
type: "boolean",
|
||||
defaultValue: "false",
|
||||
secret: false,
|
||||
@@ -376,7 +376,22 @@ const configVariables: ConfigVariables = {
|
||||
defaultValue: "",
|
||||
secret: false,
|
||||
},
|
||||
}
|
||||
},
|
||||
} satisfies ConfigVariables;
|
||||
|
||||
export type YamlConfig = {
|
||||
[Category in keyof typeof configVariables]: {
|
||||
[Key in keyof (typeof configVariables)[Category]]: string;
|
||||
};
|
||||
} & {
|
||||
initUser: {
|
||||
enabled: string;
|
||||
username: string;
|
||||
email: string;
|
||||
password: string;
|
||||
isAdmin: boolean;
|
||||
ldapDN: string;
|
||||
};
|
||||
};
|
||||
|
||||
type ConfigVariables = {
|
||||
@@ -433,7 +448,7 @@ async function migrateConfigVariables() {
|
||||
for (const existingConfigVariable of existingConfigVariables) {
|
||||
const configVariable =
|
||||
configVariables[existingConfigVariable.category]?.[
|
||||
existingConfigVariable.name
|
||||
existingConfigVariable.name
|
||||
];
|
||||
|
||||
// Delete the config variable if it doesn't exist in the seed
|
||||
|
||||
Reference in New Issue
Block a user