OAuth2.0 Server stack how to use state to prevent CSRF? for draft2.0 v20

后端 未结 3 1123
刺人心
刺人心 2020-12-13 21:45

I am using PHP library for OAuth2.0 v20

In draft20, there is a mention of the use of state to prevent CSRF

So far, my own web app that implements this PHP li

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 22:15

    As the "state" is just a random string, making something like this should do the trick:

    $state = md5(uniqid(rand(), TRUE));
    

    Just remember to save it in your session so you can check it later on.

提交回复
热议问题