fix: openId.issuer config not loading from env vars (#6061)

* fix: openId.issuer config loading from env vars

* add release note

* [autofix.ci] apply automated fixes

* remove unused directive

* move test to the right place

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Lewis Chan
2025-11-06 07:57:02 +08:00
committed by GitHub
parent a2fa74ca8d
commit 12923a87eb
4 changed files with 36 additions and 3 deletions

View File

@@ -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');

View File

@@ -205,8 +205,7 @@ const configSchema = convict({
},
issuer: {
doc: 'OpenID issuer',
format: Object,
default: {},
name: {
doc: 'Name of the provider',
default: '',

View File

@@ -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,
);
});
});

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [lwschan]
---
fix: openId.issuer config not loading from env vars