Support .well-known/openid-configuration directly

This commit is contained in:
Johannes Zellner
2023-03-20 15:19:38 +01:00
parent 98b93537ac
commit 8a1cb6b9b3
+11 -1
View File
@@ -6,11 +6,14 @@ exports = module.exports = {
const assert = require('assert'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
domains = require('./domains.js'),
ejs = require('ejs'),
fs = require('fs'),
mail = require('./mail.js'),
settings = require('./settings.js');
safe = require('safetydance'),
settings = require('./settings.js'),
superagent = require('superagent');
const MAIL_AUTOCONFIG_EJS = fs.readFileSync(__dirname + '/autoconfig.xml.ejs', { encoding: 'utf8' });
@@ -35,6 +38,13 @@ async function get(domain, location) {
if (!domainObject.wellKnown || !(location in domainObject.wellKnown)) throw new BoxError(BoxError.NOT_FOUND, 'No custom well-known config');
return { type, body: domainObject.wellKnown[location] };
} else if (location === 'openid-configuration') {
// the oidc-provider module does not expose this in javascript but only via a route handler
// we have to use the external route even
const [error, result] = await safe(superagent.get(`https://${settings.dashboardFqdn()}/api/v1/oidc/.well-known/openid-configuration`));
if (error) return new BoxError(BoxError.INTERNAL_ERROR, 'unable to connect to internal OpenID routes');
return { type: 'application/json', body: result.body };
} else {
throw new BoxError(BoxError.NOT_FOUND, 'No custom well-known config');
}