这个问题我已经有一段时间了。我正在尝试通过steam按钮添加一个登录,该按钮在登录时不仅检索用户的id,还验证签名。steam使用openid 2.0。

我遵循了文件

here

. 我已经仔细地遵循了这些步骤,花了一天中的大部分时间来尝试解决这个问题。我的代码是:

let s = data['openid.signed'].split(',');

let x = Buffer.from(s.map(x => `${x}:${data['openid.' + x]}`).join('\n') + '\n', 'utf8');

let c = crypto.createHash('sha1').update(x).digest('base64');

console.log(x.toString('utf8')); // This is the key:value string

console.log(c); // This is the final result; the generated signature

其中data是来自openid提供者的响应。

登录中

x

(键:值对字符串)提供预期的输出:

signed:signed,op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle

op_endpoint:https://steamcommunity.com/openid/login

claimed_id:https://steamcommunity.com/openid/id/765611981[1234567]

identity:https://steamcommunity.com/openid/id/765611981[1234567]

return_to:http://127.0.0.1:8000/resolve

response_nonce:2018-12-01T17:53: [some_hash]=

assoc_handle:1234567890

但是,我生成的哈希

c

与给定签名不匹配,

openid.sig

. 请注意,我使用

\n

在上面key:value对字符串的末尾,这就是我解释文档的方式。

注意事项。

我需要身份验证的原因是我想将STEAM帐户连接到我网站上的帐户,通过STEAM登录可以让您完全访问我网站上的帐户,这意味着用户不能简单地输入另一个用户id并访问他们的帐户(重播攻击)是非常重要的。因此,我需要以某种方式验证签名。

我以前从未和openid合作过,所以请原谅我的任何愚蠢的错误。我强烈建议您阅读上面链接的文档,这样您就可以验证我所做的是正确的。

谨致问候,

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐