fix: error in toArrayConfig

If an empty string or undefined is provided the method should not return [], but undefined instead. This way defaults defined in Joi function as expected.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-03-16 20:13:41 +01:00
parent 5db2229771
commit 91d7f1a529
4 changed files with 19 additions and 15 deletions

View file

@ -66,7 +66,7 @@ export interface AuthConfig {
searchAttributes: string[];
usernameField: string;
useridField: string;
tlsCa: string[];
tlsCa?: string[];
}[];
saml: {
identifier: string;
@ -78,8 +78,8 @@ export interface AuthConfig {
identifierFormat: string;
disableRequestedAuthnContext: string;
groupAttribute: string;
requiredGroups: string[];
externalGroups: string;
requiredGroups?: string[];
externalGroups?: string[];
attribute: {
id: string;
username: string;
@ -241,18 +241,18 @@ const authSchema = Joi.object({
export default registerAs('authConfig', () => {
// ToDo: Validate these with Joi to prevent duplicate entries?
const gitlabNames = toArrayConfig(process.env.HD_AUTH_GITLABS, ',').map(
const gitlabNames = (
toArrayConfig(process.env.HD_AUTH_GITLABS, ',') ?? []
).map((name) => name.toUpperCase());
const ldapNames = (toArrayConfig(process.env.HD_AUTH_LDAPS, ',') ?? []).map(
(name) => name.toUpperCase(),
);
const ldapNames = toArrayConfig(process.env.HD_AUTH_LDAPS, ',').map((name) =>
name.toUpperCase(),
);
const samlNames = toArrayConfig(process.env.HD_AUTH_SAMLS, ',').map((name) =>
name.toUpperCase(),
);
const oauth2Names = toArrayConfig(process.env.HD_AUTH_OAUTH2S, ',').map(
const samlNames = (toArrayConfig(process.env.HD_AUTH_SAMLS, ',') ?? []).map(
(name) => name.toUpperCase(),
);
const oauth2Names = (
toArrayConfig(process.env.HD_AUTH_OAUTH2S, ',') ?? []
).map((name) => name.toUpperCase());
const gitlabs = gitlabNames.map((gitlabName) => {
return {