forked from eggjs/security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
24 lines (18 loc) · 767 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'use strict';
const safeRedirect = require('./lib/safe_redirect');
const utils = require('./lib/utils');
const assert = require('assert');
module.exports = app => {
app.config.coreMiddleware.push('securities');
if (app.config.security.csrf && app.config.security.csrf.enable) {
const { ignoreJSON, type } = app.config.security.csrf;
if (ignoreJSON) {
app.deprecate('[egg-security] `app.config.security.csrf.ignoreJSON` is not safe now, please disable it.');
}
const { isLegalType } = utils.checkCsrfType(type);
assert(isLegalType, '[egg-security] `config.security.csrf.type` must be one of ' + utils.allowTypeList.join(', '));
}
// patch response.redirect
safeRedirect(app);
utils.preprocessConfig(app.config.security);
};