Rails 新浪微博授权 参数 state 的问题

tsinghan · September 30, 2013 · Last by TsingHan replied at September 30, 2013 · 2236 hits

我在授权链接上用这个 state 参数传值,然后在 callback 函数的时候拿到它,例如

user_omniauth_authorize_path(:weibo state: 1)

但是 callback 回来后的 state 变成

"state"=>"9bde1b407f3402edcafdf072b283d33179e837b95ae852f4"

我用的是这个 gem omniauth-weibo-oauth2

我感觉是不是会 url 编码了?还是什么问题?

ps:腾讯微博的没有问题,返回正常

感觉不是 url 编码,还是被加密了?

不折腾 state 这个参数了,换了种办法 user_omniauth_authorize_path(:weibo, :origin => "123")

然后在 callback 中 request.env['omniauth.origin'] 可以拿的到这个值

https://github.com/intridea/omniauth/wiki/Saving-User-Location

ps:谁知道 state 这个问题,继续回帖~~~

是不是 state 参数用来防止攻击了。

#3 楼 @zhangyuan 看了文档说是有防止 csrf 攻击这个作用,但也可以记录用户请求授权页前的位置,腾讯的没问题,奇怪

You need to Sign in before reply, if you don't have an account, please Sign up first.