From 2f1729107906f445cd75401705f027545c2a6150 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Thu, 28 Jan 2021 23:28:16 +0100 Subject: [PATCH] config: Fix inconsistent env vars This should make the translation from env var name to config name and vice versa more consistent. Fixes #751 Signed-off-by: Philip Molares --- src/config/auth.config.ts | 16 ++++++++-------- src/config/csp.config.ts | 4 ++-- src/config/media.config.ts | 4 ++-- src/config/utils.ts | 16 ++++++++-------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/config/auth.config.ts b/src/config/auth.config.ts index ec36789cc..1d7ce0269 100644 --- a/src/config/auth.config.ts +++ b/src/config/auth.config.ts @@ -276,21 +276,21 @@ export default registerAs('authConfig', async () => { const samls = samlNames.map((samlName) => { return { providerName: process.env[`HD_AUTH_SAML_${samlName}_PROVIDER_NAME`], - idpSsoUrl: process.env[`HD_AUTH_SAML_${samlName}_IDPSSOURL`], - idpCert: process.env[`HD_AUTH_SAML_${samlName}_IDPCERT`], - clientCert: process.env[`HD_AUTH_SAML_${samlName}_CLIENTCERT`], + idpSsoUrl: process.env[`HD_AUTH_SAML_${samlName}_IDP_SSO_URL`], + idpCert: process.env[`HD_AUTH_SAML_${samlName}_IDP_CERT`], + clientCert: process.env[`HD_AUTH_SAML_${samlName}_CLIENT_CERT`], issuer: process.env[`HD_AUTH_SAML_${samlName}_ISSUER`], identifierFormat: - process.env[`HD_AUTH_SAML_${samlName}_IDENTIFIERFORMAT`], + process.env[`HD_AUTH_SAML_${samlName}_IDENTIFIER_FORMAT`], disableRequestedAuthnContext: - process.env[`HD_AUTH_SAML_${samlName}_DISABLEREQUESTEDAUTHNCONTEXT`], - groupAttribute: process.env[`HD_AUTH_SAML_${samlName}_GROUPATTRIBUTE`], + process.env[`HD_AUTH_SAML_${samlName}_DISABLE_REQUESTED_AUTHN_CONTEXT`], + groupAttribute: process.env[`HD_AUTH_SAML_${samlName}_GROUP_ATTRIBUTE`], requiredGroups: toArrayConfig( - process.env[`HD_AUTH_SAML_${samlName}_REQUIREDGROUPS`], + process.env[`HD_AUTH_SAML_${samlName}_REQUIRED_GROUPS`], '|', ), externalGroups: toArrayConfig( - process.env[`HD_AUTH_SAML_${samlName}_EXTERNALGROUPS`], + process.env[`HD_AUTH_SAML_${samlName}_EXTERNAL_GROUPS`], '|', ), attribute: { diff --git a/src/config/csp.config.ts b/src/config/csp.config.ts index 000118a31..15da192c9 100644 --- a/src/config/csp.config.ts +++ b/src/config/csp.config.ts @@ -15,14 +15,14 @@ export interface CspConfig { const cspSchema = Joi.object({ enable: Joi.boolean().default(true).optional().label('HD_CSP_ENABLE'), - reportURI: Joi.string().optional().label('HD_CSP_REPORTURI'), + reportURI: Joi.string().optional().label('HD_CSP_REPORT_URI'), }); export default registerAs('cspConfig', async () => { const cspConfig = cspSchema.validate( { enable: process.env.HD_CSP_ENABLE || true, - reportURI: process.env.HD_CSP_REPORTURI, + reportURI: process.env.HD_CSP_REPORT_URI, }, { abortEarly: false, diff --git a/src/config/media.config.ts b/src/config/media.config.ts index cd890f670..5f1d1e440 100644 --- a/src/config/media.config.ts +++ b/src/config/media.config.ts @@ -68,7 +68,7 @@ const mediaSchema = Joi.object({ imgur: Joi.when('...use', { is: Joi.valid(BackendType.IMGUR), then: Joi.object({ - clientID: Joi.string().label('HD_MEDIA_BACKEND_IMGUR_CLIENTID'), + clientID: Joi.string().label('HD_MEDIA_BACKEND_IMGUR_CLIENT_ID'), }), otherwise: Joi.optional(), }), @@ -96,7 +96,7 @@ export default registerAs('mediaConfig', async () => { container: process.env.HD_MEDIA_BACKEND_AZURE_CONTAINER, }, imgur: { - clientID: process.env.HD_MEDIA_BACKEND_IMGUR_CLIENTID, + clientID: process.env.HD_MEDIA_BACKEND_IMGUR_CLIENT_ID, }, }, }, diff --git a/src/config/utils.ts b/src/config/utils.ts index d6d02e2cf..041d91301 100644 --- a/src/config/utils.ts +++ b/src/config/utils.ts @@ -54,18 +54,18 @@ export const replaceAuthErrorsWithEnvironmentVariables = ( message = message.replace('.usernameField', '_USERNAME_FIELD'); message = message.replace('.useridField', '_USERID_FIELD'); message = message.replace('.tlsCa', '_TLS_CA'); - message = message.replace('.idpSsoUrl', '_IDPSSOURL'); - message = message.replace('.idpCert', '_IDPCERT'); - message = message.replace('.clientCert', '_CLIENTCERT'); + message = message.replace('.idpSsoUrl', '_IDP_SSO_URL'); + message = message.replace('.idpCert', '_IDP_CERT'); + message = message.replace('.clientCert', '_CLIENT_CERT'); message = message.replace('.issuer', '_ISSUER'); - message = message.replace('.identifierFormat', '_IDENTIFIERFORMAT'); + message = message.replace('.identifierFormat', '_IDENTIFIER_FORMAT'); message = message.replace( '.disableRequestedAuthnContext', - '_DISABLEREQUESTEDAUTHNCONTEXT', + '_DISABLE_REQUESTED_AUTHN_CONTEXT', ); - message = message.replace('.groupAttribute', '_GROUPATTRIBUTE'); - message = message.replace('.requiredGroups', '_REQUIREDGROUPS'); - message = message.replace('.externalGroups', '_EXTERNALGROUPS'); + message = message.replace('.groupAttribute', '_GROUP_ATTRIBUTE'); + message = message.replace('.requiredGroups', '_REQUIRED_GROUPS'); + message = message.replace('.externalGroups', '_EXTERNAL_GROUPS'); message = message.replace('.attribute.id', '_ATTRIBUTE_ID'); message = message.replace('.attribute.username', '_ATTRIBUTE_USERNAME'); message = message.replace('.attribute.email', '_ATTRIBUTE_USERNAME');