需要伪代码来帮助我理解oauth
有人可以帮助我了解如何使用 oauth 身份验证来允许用户访问我网站的安全部分吗?
我只是在寻找一些伪代码。
例如,当某人使用其 facebook id 进行身份验证时,
我是否需要存储他们已通过身份验证的事实,然后使用 facebook 创建的会话 id 并将其与存储在我的数据库中的会话 id 进行比较?
如果是,如果 Facebook 用户从他们的 Facebook 帐户中删除我的应用程序,然后最近决定再次使用相同的 ID 再次登录我的网站,会发生什么?他们的会话 ID 是否仍与我数据库中存储的会话 ID 匹配?
如果不是,我是否不会在数据库中存储任何内容?
Can someone please help me understand how to use oauth authentication to allow users access to secure sections of my website?
I am just looking for some psudo code.
For example, when someone gets authenticated by using their facebook id,
do I need to store the fact they have been authenticated, then use the session id created by facebook in the future and compare it with the session id's stored in my database?
If yes, what happens if the facebook user removes my application from their facebook account, then latest decide to use the same id again to login to my website again? Will their session id still match the one stored in my database?
if no, do I not store anything in my database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您的用户和 Facebook 之间的交互完成后,您将获得一个令牌,您应该将其与您的用户关联并保留在数据库中。您将能够使用它一段时间(由 facebook 配置),并且应该始终期待 HTTP 未经授权的响应。在这种情况下,您必须向用户提供 Facebook 页面,让他可以再次输入用户名密码。
When the interaction between your user and facebook is finished, you'll be given a token which you should associate with your user and persist in database. You'll be able to use it for some time (configured by facebook) and should always expect HTTP Unauthorized response. In that case you have to present facebook page to the user where he can put his username password again.