Skip to content

Commit

Permalink
docs: security match and ignore (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse committed Mar 28, 2017
1 parent 7ab3791 commit 1486705
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/source/zh-cn/basics/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ module.exports = {
};
```

### match & ignore
### match ignore

match 和 ignore 支持的参数都一样,只是作用完全相反,match 和 ignore 不允许同时配置。

Expand Down
17 changes: 13 additions & 4 deletions docs/source/zh-cn/core/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ exports.security = {

### match 和 ignore

如果只想开启针对某一路径,则配置 match 选项,例如只针对 `/example` 开启 CSP
match 和 ignore 使用方法和格式与[中间件通用配置](../basics/middleware.md#match和ignore)一致。

如果只想开启针对某一路径,则配置 match 选项,例如只针对 `/example` 开启 CSP:

```js
exports.security = {
Expand All @@ -50,7 +52,6 @@ exports.security = {
},
},
};

```

如果需要针对某一路径忽略某安全选项,则配置 ignore 选项,例如针对 `/example` 关闭 xframe,以便合作商户能够嵌入我们的页面:
Expand All @@ -64,10 +65,18 @@ exports.security = {
},
},
};

```

**注意:不能同时存在 match 和 ignore ,否则会报错。**
如果要针对内部 ip 关闭部分安全防范:

```js
exports.security = {
csrf: {
// 判断是否需要 ignore 的方法,请求上下文 context 作为第一个参数
ignore: ctx => isInnerIp(ctx.ip),
},
}
```

下面我们会针对具体的场景,来讲解如何使用框架提供的安全方案进行 Web 安全防范。

Expand Down

0 comments on commit 1486705

Please sign in to comment.