GithubHelp home page GithubHelp logo

csrf-demo's Introduction

CSRF防御demo

nodejs端防御规则

  • step1,判别是否post,否的话无需防御
  • step2,判别是否当前url属于白名单:是则无需防御
  • step3,获取cookie ppu:如果未获取,则认为无需防御
  • step4,ppu存在:获取 http header x-csrf-token
  • step5,判断x-csrf-token与ppu是否相同:是则认为通过校验,否则拒绝服务

browser端请求规则

  • step1,POST请求时,添加header x-csrf-token,值为PPU cookie
  • step2,cookie无PPU时,x-csrf-token可以为空,或者null;或者干脆不设置x-csrf-token

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.