From 6a5e3e204f0d9877a969140114458e021b7e6b0b Mon Sep 17 00:00:00 2001 From: keshan Date: Thu, 3 Dec 2020 09:07:04 +0530 Subject: [PATCH] Updated comments and code to reflect feedbacks --- .changeset/unlucky-kiwis-rescue.md | 11 +++++++++- packages/core/config.d.ts | 8 +++++++- packages/core/src/api-wrappers/defaultApis.ts | 20 +++++++++---------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.changeset/unlucky-kiwis-rescue.md b/.changeset/unlucky-kiwis-rescue.md index 0ac7d8f299..71afaeb44a 100644 --- a/.changeset/unlucky-kiwis-rescue.md +++ b/.changeset/unlucky-kiwis-rescue.md @@ -2,4 +2,13 @@ '@backstage/core': minor --- -Introducing env prop to have configurable authentication env +Introducing a new optional property within `app-config.yaml` called `auth.environment` to have configurable environment value for `auth.providers` + +**Default Value:** 'development' + +**Optional Values:** 'production' | 'development' + +**Migration-steps:** + +- To override the default value, one could simply introduce the new property `environment` within the `auth` section of the `config.yaml` +- re-run the build to reflect the changed configs diff --git a/packages/core/config.d.ts b/packages/core/config.d.ts index e13c00e561..a6f95ae71c 100644 --- a/packages/core/config.d.ts +++ b/packages/core/config.d.ts @@ -62,9 +62,15 @@ export interface Config { timezone: string; }[]; }; + + /** + * Configuration that provides information on available authentication providers configured for app + */ auth?: { /** - * The environment config added to be able to change the authentication environment. + * The 'environment' attribute added as an optional parameter to have configurable environment value for `auth.providers`. + * default value: 'development' + * optional values: 'development' | 'production' * @visibility frontend */ environment?: string; diff --git a/packages/core/src/api-wrappers/defaultApis.ts b/packages/core/src/api-wrappers/defaultApis.ts index 58cf50fca0..d044b50b7a 100644 --- a/packages/core/src/api-wrappers/defaultApis.ts +++ b/packages/core/src/api-wrappers/defaultApis.ts @@ -84,7 +84,7 @@ export const defaultApis = [ GoogleAuth.create({ discoveryApi, oauthRequestApi, - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), createApiFactory({ @@ -98,7 +98,7 @@ export const defaultApis = [ MicrosoftAuth.create({ discoveryApi, oauthRequestApi, - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), createApiFactory({ @@ -113,7 +113,7 @@ export const defaultApis = [ discoveryApi, oauthRequestApi, defaultScopes: ['read:user'], - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), createApiFactory({ @@ -127,7 +127,7 @@ export const defaultApis = [ OktaAuth.create({ discoveryApi, oauthRequestApi, - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), createApiFactory({ @@ -141,7 +141,7 @@ export const defaultApis = [ GitlabAuth.create({ discoveryApi, oauthRequestApi, - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), createApiFactory({ @@ -155,7 +155,7 @@ export const defaultApis = [ Auth0Auth.create({ discoveryApi, oauthRequestApi, - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), createApiFactory({ @@ -169,7 +169,7 @@ export const defaultApis = [ OAuth2.create({ discoveryApi, oauthRequestApi, - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), createApiFactory({ @@ -181,7 +181,7 @@ export const defaultApis = [ factory: ({ discoveryApi, configApi }) => SamlAuth.create({ discoveryApi, - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), createApiFactory({ @@ -195,7 +195,7 @@ export const defaultApis = [ OneLoginAuth.create({ discoveryApi, oauthRequestApi, - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), createApiFactory({ @@ -214,7 +214,7 @@ export const defaultApis = [ title: 'Your Identity Provider', icon: OAuth2Icon, }, - environment: configApi.getString('auth.environment'), + environment: configApi.getOptionalString('auth.environment'), }), }), ];