diff options
author | Aurélien Bertron <aurelienbertron@gmail.com> | 2018-07-31 14:04:26 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-31 15:40:29 +0200 |
commit | 80e36cd9facb56b330be3e4f1c5ba253cc78c308 (patch) | |
tree | 807d8a642ae99ec3f05597e19ebe1ca5dc849582 /server/controllers/api/config.ts | |
parent | 59390818384baa0ffc0cb71af2e67350c6b39172 (diff) | |
download | PeerTube-80e36cd9facb56b330be3e4f1c5ba253cc78c308.tar.gz PeerTube-80e36cd9facb56b330be3e4f1c5ba253cc78c308.tar.zst PeerTube-80e36cd9facb56b330be3e4f1c5ba253cc78c308.zip |
Add audit logs in various modules
- Videos
- Videos comments
- Users
- Videos channels
- Videos abuses
- Custom config
Diffstat (limited to 'server/controllers/api/config.ts')
-rw-r--r-- | server/controllers/api/config.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 9c1b2818c..411b13539 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -9,10 +9,13 @@ import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' | |||
9 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' | 9 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' |
10 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' | 10 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' |
11 | import { ClientHtml } from '../../lib/client-html' | 11 | import { ClientHtml } from '../../lib/client-html' |
12 | import { CustomConfigAuditView, auditLoggerFactory } from '../../helpers/audit-logger' | ||
12 | 13 | ||
13 | const packageJSON = require('../../../../package.json') | 14 | const packageJSON = require('../../../../package.json') |
14 | const configRouter = express.Router() | 15 | const configRouter = express.Router() |
15 | 16 | ||
17 | const auditLogger = auditLoggerFactory('config') | ||
18 | |||
16 | configRouter.get('/about', getAbout) | 19 | configRouter.get('/about', getAbout) |
17 | configRouter.get('/', | 20 | configRouter.get('/', |
18 | asyncMiddleware(getConfig) | 21 | asyncMiddleware(getConfig) |
@@ -119,6 +122,11 @@ async function getCustomConfig (req: express.Request, res: express.Response, nex | |||
119 | async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 122 | async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { |
120 | await unlinkPromise(CONFIG.CUSTOM_FILE) | 123 | await unlinkPromise(CONFIG.CUSTOM_FILE) |
121 | 124 | ||
125 | auditLogger.delete( | ||
126 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | ||
127 | new CustomConfigAuditView(customConfig()) | ||
128 | ) | ||
129 | |||
122 | reloadConfig() | 130 | reloadConfig() |
123 | ClientHtml.invalidCache() | 131 | ClientHtml.invalidCache() |
124 | 132 | ||
@@ -129,6 +137,7 @@ async function deleteCustomConfig (req: express.Request, res: express.Response, | |||
129 | 137 | ||
130 | async function updateCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 138 | async function updateCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { |
131 | const toUpdate: CustomConfig = req.body | 139 | const toUpdate: CustomConfig = req.body |
140 | const oldCustomConfigAuditKeys = new CustomConfigAuditView(customConfig()) | ||
132 | 141 | ||
133 | // Force number conversion | 142 | // Force number conversion |
134 | toUpdate.cache.previews.size = parseInt('' + toUpdate.cache.previews.size, 10) | 143 | toUpdate.cache.previews.size = parseInt('' + toUpdate.cache.previews.size, 10) |
@@ -150,6 +159,13 @@ async function updateCustomConfig (req: express.Request, res: express.Response, | |||
150 | ClientHtml.invalidCache() | 159 | ClientHtml.invalidCache() |
151 | 160 | ||
152 | const data = customConfig() | 161 | const data = customConfig() |
162 | |||
163 | auditLogger.update( | ||
164 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | ||
165 | new CustomConfigAuditView(data), | ||
166 | oldCustomConfigAuditKeys | ||
167 | ) | ||
168 | |||
153 | return res.json(data).end() | 169 | return res.json(data).end() |
154 | } | 170 | } |
155 | 171 | ||