- split config from user data to config.json, add config.hson.template - moved default user data localdb to root folder - moved pve, localdb, ldap backend handlers to backends sub folder - add dynamic loading of all backends - add dynamic mapping for auth backends to support multiple auth sources - update affected endpoints
29 lines
681 B
JavaScript
29 lines
681 B
JavaScript
import { Router } from "express";
|
|
export const router = Router({ mergeParams: true });
|
|
|
|
const checkAuth = global.utils.checkAuth;
|
|
|
|
/**
|
|
* GET - get db global resource configuration
|
|
* responses:
|
|
* - 200: Object
|
|
*/
|
|
router.get("/config/:key", async (req, res) => {
|
|
const params = {
|
|
key: req.params.key
|
|
};
|
|
// check auth
|
|
const auth = await checkAuth(req.cookies, res);
|
|
if (!auth) {
|
|
return;
|
|
}
|
|
const allowKeys = ["resources"];
|
|
if (allowKeys.includes(params.key)) {
|
|
const config = global.config;
|
|
res.status(200).send(config[params.key]);
|
|
}
|
|
else {
|
|
res.status(401).send({ auth: false, error: `User is not authorized to access /global/config/${params.key}.` });
|
|
}
|
|
});
|