diff --git a/packages/sync-server/src/app.ts b/packages/sync-server/src/app.ts index d1dbc4d041..079fb2058a 100644 --- a/packages/sync-server/src/app.ts +++ b/packages/sync-server/src/app.ts @@ -177,7 +177,6 @@ export async function run() { const openIdConfig = config?.getProperties()?.openId; if ( openIdConfig?.discoveryURL || - // @ts-expect-error FIXME no types for config yet openIdConfig?.issuer?.authorization_endpoint ) { console.log('OpenID configuration found. Preparing server to use it'); diff --git a/packages/sync-server/src/load-config.js b/packages/sync-server/src/load-config.js index 43794ad52f..82183ce310 100644 --- a/packages/sync-server/src/load-config.js +++ b/packages/sync-server/src/load-config.js @@ -205,8 +205,7 @@ const configSchema = convict({ }, issuer: { doc: 'OpenID issuer', - format: Object, - default: {}, + name: { doc: 'Name of the provider', default: '', diff --git a/packages/sync-server/src/load-config.test.js b/packages/sync-server/src/load-config.test.js index 0c85d84ac1..26e9c35440 100644 --- a/packages/sync-server/src/load-config.test.js +++ b/packages/sync-server/src/load-config.test.js @@ -110,3 +110,32 @@ describe('tokenExpiration format', () => { ); }); }); + +describe('config schema', () => { + it('should parse nested object from environment variables correctly', () => { + const authorizationEndpoint = + 'https://testprovider.com/.well-known/openid-configuration'; + process.env.TEST_OPENID_AUTHORIZATION_ENDPOINT = authorizationEndpoint; + + const testSchema = convict({ + openId: { + doc: 'OpenID authentication settings.', + + issuer: { + doc: 'OpenID issuer', + + authorization_endpoint: { + doc: 'Authorization endpoint', + default: '', + format: String, + env: 'TEST_OPENID_AUTHORIZATION_ENDPOINT', + }, + }, + }, + }); + expect(() => testSchema.validate()).not.toThrow(); + expect(testSchema.get('openId.issuer.authorization_endpoint')).toBe( + authorizationEndpoint, + ); + }); +}); diff --git a/upcoming-release-notes/6061.md b/upcoming-release-notes/6061.md new file mode 100644 index 0000000000..0a1f600a5a --- /dev/null +++ b/upcoming-release-notes/6061.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [lwschan] +--- + +fix: openId.issuer config not loading from env vars