Egg.js Post提交数据_Egg.js安全机制 CSRF 的防范

发布于 5 年前 作者 sinazl 3127 次浏览 最后一次编辑是 5 年前 来自 分享

Egg.js Post提交数据、Egg.js安全机制 CSRF 的防范视频教程下载地址

百度网盘:https://pan.baidu.com/s/1t6XHpny8-H8mApLkzcsS8w 地址失效访问:https://www.itying.com/goods-941.html

1、Egg安全机制 CSRF 的防范

http://eggjs.org/zh-cn/core/security.html

2、Egg Post提交数据

1.提交数据

<form action="/news/doAdd?_csrf=<%=csrf%> " method="POST">
    
      用户名: <input type="text" name="username" /> <br><br>  

      密 码: <input type="text" name="password" type="password" /> 

      <button type="submit">提交</button>
</form>

2、提交数据的另一种方案

<form action="/news/doAdd> " method="POST">

      <input type="hidden" name="_csrf" value="<%=csrf%>">
      用户名: <input type="text" name="username" /> <br><br>  

      密 码: <input type="text" name="password" type="password" /> 

      <button type="submit">提交</button>
</form>

3、获取数据(egg.js获取数据不需要配置中间件直接通过下面方式获取)

this.ctx.request.body

4、Egg.js中获取csrf的值

egg中获取csrf

this.ctx.csrf     
回到顶部