Authored by 徐炜

参数黑名单过滤

... ... @@ -99,6 +99,7 @@ app.use((req, res, next) => {
// dispatcher
try {
const user = require('./doraemon/middleware/user');
const reqParamsFilter = require('./doraemon/middleware/req-params-filter');
const subDomain = require('./doraemon/middleware/sub-domain');
const itemNameHandler = require('./doraemon/middleware/item-name-handler');
const setYohoData = require('./doraemon/middleware/set-yoho-data');
... ... @@ -110,6 +111,7 @@ try {
const pageCache = require('./doraemon/middleware/page-cache');
// YOHO 前置中间件
app.use(reqParamsFilter());
app.use(subDomain());
app.use(itemNameHandler);
app.use(setYohoData());
... ...
const _ = require('lodash');
// 黑名单参数
const BLACK_LIST = [
'client_secret',
'method'
];
module.exports = () => {
return (req, res, next) => {
if (req.query) {
_.forEach(BLACK_LIST, (key) => {
if (req.query[key]) {
delete req.query[key];
}
});
}
next();
};
};
... ...