mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-07 18:03:33 +00:00
Supporting open-appsec
This commit is contained in:
49
backend/routes/api/openappsec-settings.js
Executable file
49
backend/routes/api/openappsec-settings.js
Executable file
@@ -0,0 +1,49 @@
|
||||
const express = require('express');
|
||||
const jwtdecode = require('../../lib/express/jwt-decode');
|
||||
const internalOpenappsecSetting = require('../../internal/setting-openappsec');
|
||||
|
||||
let router = express.Router({
|
||||
caseSensitive: true,
|
||||
strict: true,
|
||||
mergeParams: true
|
||||
});
|
||||
|
||||
/**
|
||||
* /api/openappsec-settings
|
||||
*/
|
||||
router
|
||||
.route('/')
|
||||
.options((req, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
|
||||
/**
|
||||
* GET /api/openappsec-settings
|
||||
*
|
||||
* Retrieve the open-appsec local policy.
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
return internalOpenappsecSetting.getLocalPolicy(res.locals.access)
|
||||
.then((policy) => {
|
||||
res.status(200)
|
||||
.send(policy);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
|
||||
/**
|
||||
* PUT /api/openappsec-settings
|
||||
*
|
||||
* Update the open-appsec local policy.
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
return internalOpenappsecSetting.updateLocalPolicy(res.locals.access, req.body)
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
||||
module.exports = router;
|
Reference in New Issue
Block a user