大佬教程收集整理的这篇文章主要介绍了在 Rust 中验证 Google 登录 ID 令牌,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想验证在尝试 Google 登录成功后返回的 Google ID 令牌。我有一个基于 Rust 的 web 应用程序,我:
通过 @R_404_3715@ 提供 Google 登录,在成功验证后,我会返回一个 Google ID 令牌。
我的 @R_404_3715@ 代码将此 Google ID 令牌连同其他信息(即用户的帐户 ID、当前电子邮件等)提交到我的后端服务器(用 Rust 编写)。
我想通过 Google 官方文档 https://developers.google.com/identity/sign-in/web/BACkend-auth 中引用的说明验证此 ID 令牌的完整性,然后才能“相信”提交的用户信息(即用户的帐户 ID、当前电子邮件等)是有效的,不是恶意请求。
我想要实现的示例:Validate Google Id Token
我尝试过的:
cargo check
updating crates.io index
error: Failed to SELEct a version for the requirement `untrusted = "^0.5"`
candIDate versions found which dIDn't match: 0.7.1,0.7.0,0.6.2
LOCATIOn searched: crates.io index
required by package `webpki-roots v0.10.0`
... which is depended on by `hyper-rustls v0.6.0`
... which is depended on by `Google-signin v0.3.0`
... which is depended on by `<my project> v0.0.1 (<my project>)`
似乎 crate 到 repo 的链接已损坏,因此无法提交问题。
人们在 Rust 中使用什么来验证 ID 令牌?
不幸的是,rust 没有官方 sdk,而且这两个也不好,因为它们使用令牌追溯端点进行验证,因此每个令牌验证都会有延迟。
最好在本地获取和缓存 jwks 并进行验证,到目前为止我发现的最好的箱子是 https://crates.io/crates/jwks-client 。我对 Firebase ID 令牌感兴趣,因此 jwks 网址是 https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com 。它工作正常,但有一些严重的限制:
还有 https://medium.com/@maylukas/firebase-token-authentication-in-rust-a1885f0982df 似乎是一个非常有用的指南
以上是大佬教程为你收集整理的在 Rust 中验证 Google 登录 ID 令牌全部内容,希望文章能够帮你解决在 Rust 中验证 Google 登录 ID 令牌所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。