oidc: Provide custom error page
This commit is contained in:
33
src/oidc.js
33
src/oidc.js
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user