feat(config): warn user about not yet supported config

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2023-10-07 12:05:36 +02:00
parent d43da06ec1
commit 5335c48df7
4 changed files with 53 additions and 3 deletions

View file

@ -221,15 +221,30 @@ export default registerAs('authConfig', () => {
const gitlabNames = (
toArrayConfig(process.env.HD_AUTH_GITLABS, ',') ?? []
).map((name) => name.toUpperCase());
if (gitlabNames.length !== 0) {
throw new Error(
"GitLab auth is currently not yet supported. Please don't configure it",
);
}
const ldapNames = (
toArrayConfig(process.env.HD_AUTH_LDAP_SERVERS, ',') ?? []
).map((name) => name.toUpperCase());
const samlNames = (toArrayConfig(process.env.HD_AUTH_SAMLS, ',') ?? []).map(
(name) => name.toUpperCase(),
);
if (samlNames.length !== 0) {
throw new Error(
"SAML auth is currently not yet supported. Please don't configure it",
);
}
const oauth2Names = (
toArrayConfig(process.env.HD_AUTH_OAUTH2S, ',') ?? []
).map((name) => name.toUpperCase());
if (oauth2Names.length !== 0) {
throw new Error(
"OAuth2 auth is currently not yet supported. Please don't configure it",
);
}
const gitlabs = gitlabNames.map((gitlabName) => {
return {
@ -334,6 +349,25 @@ export default registerAs('authConfig', () => {
};
});
if (
process.env.HD_AUTH_GITHUB_CLIENT_ID !== undefined ||
process.env.HD_AUTH_GITHUB_CLIENT_SECRET !== undefined
) {
throw new Error(
"GitHub config is currently not yet supported. Please don't configure it",
);
}
if (
process.env.HD_AUTH_GOOGLE_CLIENT_ID !== undefined ||
process.env.HD_AUTH_GOOGLE_CLIENT_SECRET !== undefined ||
process.env.HD_AUTH_GOOGLE_APP_KEY !== undefined
) {
throw new Error(
"Google config is currently not yet supported. Please don't configure it",
);
}
const authConfig = authSchema.validate(
{
session: {

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -19,6 +19,15 @@ const cspSchema = Joi.object({
});
export default registerAs('cspConfig', () => {
if (
process.env.HD_CSP_ENABLE !== undefined ||
process.env.HD_CSP_REPORT_URI !== undefined
) {
throw new Error(
"CSP config is currently not yet supported. Please don't configure it",
);
}
const cspConfig = cspSchema.validate(
{
enable: process.env.HD_CSP_ENABLE || true,

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -29,6 +29,11 @@ const schema = Joi.object({
});
export default registerAs('externalServicesConfig', () => {
if (process.env.HD_IMAGE_PROXY !== undefined) {
throw new Error(
"HD_IMAGE_PROXY is currently not yet supported. Please don't configure it",
);
}
const externalConfig = schema.validate(
{
plantUmlServer: process.env.HD_PLANTUML_SERVER,

View file

@ -3,4 +3,6 @@
| environment variable | default | example | description |
|------------------------|---------|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| `HD_PLANTUML_SERVER` | - | `https://www.plantuml.com/plantuml` | The PlantUML server that HedgeDoc uses to render PlantUML diagrams. If this is not configured, PlantUML diagrams won't be rendered. |
| `HD_IMAGE_PROXY` | - | `https://image-proxy.example.com` | **ToDo:** Add description |
<!--
| `HD_IMAGE_PROXY` | - | `https://image-proxy.example.com` | **ToDo:** Add description |
-->