oidc: Provide custom error page

This commit is contained in:
Johannes Zellner
2023-03-21 15:12:55 +01:00
parent 2315cf330f
commit 8d7efc5701
2 changed files with 66 additions and 9 deletions

View File

@@ -105,7 +105,7 @@ class CloudronAdapter {
} else {
this.fileStorePath = path.join(paths.OIDC_STORE_DIR, `${name}.json`);
debug(`Creating adapter for ${name} backed by ${this.fileStorePath}`);
debug(`Creating storage adapter for ${name} backed by ${this.fileStorePath}`);
let data = {};
try {
@@ -512,6 +512,27 @@ async function postLogoutSuccessSource(ctx) {
ctx.body = ejs.render(fs.readFileSync(path.join(__dirname, 'oidc_templates/post_logout.ejs'), 'utf8'), data, {});
}
async function findAccount(ctx, id) {
debug(`findAccount id:${id}`);
return {
accountId: id,
async claims(use, scope) { return await claims(id, use, scope); },
};
}
async function renderError(ctx, out, error) {
const data = {
dashboardOrigin: settings.dashboardOrigin(),
error
};
debug('renderError:', error);
ctx.type = 'html';
ctx.body = ejs.render(fs.readFileSync(path.join(__dirname, 'oidc_templates/error.ejs'), 'utf8'), data, {});
}
async function start() {
const app = express();
@@ -520,14 +541,8 @@ async function start() {
const { Provider } = await import('oidc-provider');
const configuration = {
async findAccount(ctx, id) {
debug(`findAccount id:${id}`);
return {
accountId: id,
async claims(use, scope) { return await claims(id, use, scope); },
};
},
findAccount,
renderError,
adapter: CloudronAdapter,
interactions: {
url: async function(ctx, interaction) {