oidc: use better json based file store for objects

This commit is contained in:
Johannes Zellner
2023-03-24 20:08:17 +01:00
parent 44706b9c70
commit 99e0979c2e
7 changed files with 129 additions and 47 deletions

View File

@@ -17,7 +17,7 @@ exports = module.exports = {
mailserver: require('./mailserver.js'),
network: require('./network.js'),
notifications: require('./notifications.js'),
oidcclients: require('./oidcclients.js'),
oidc: require('./oidc.js'),
profile: require('./profile.js'),
provision: require('./provision.js'),
services: require('./services.js'),

View File

@@ -1,11 +1,15 @@
'use strict';
exports = module.exports = {
get,
list,
add,
update,
remove
clients: {
get,
list,
add,
update,
del
},
destroyUserSession
};
const assert = require('assert'),
@@ -78,7 +82,7 @@ async function list(req, res, next) {
next(new HttpSuccess(200, { clients: result }));
}
async function remove(req, res, next) {
async function del(req, res, next) {
assert.strictEqual(typeof req.params.clientId, 'string');
const [error] = await safe(oidc.clients.del(req.params.clientId));
@@ -86,3 +90,12 @@ async function remove(req, res, next) {
next(new HttpSuccess(204));
}
async function destroyUserSession(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
const [error] = await safe(oidc.revokeByUserId(req.user.id));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(204));
}