使用Facebook访问令牌是一种验证用户的安全方式吗? [英] Is using the Facebook access token a secure way to validate a user?

查看:89
本文介绍了使用Facebook访问令牌是一种验证用户的安全方式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序上,用户可以登录到Facebook,然后该应用程序具有用户的访问令牌(称为abc),我想使用此令牌在我自己的服务器上创建用户。

On my app the user can sign to Facebook and the app then has the user's access token (say it's 'abc'), I want to use this token to create a user on my own server.

将此访问令牌发送到我的服务器(使用SSL)是安全的,然后使用 https://graph.facebook.com/me?access_token=abc 在我的服务器上,并检查该令牌所属的应用程序是我的 https://graph.facebook.com/app?access_token=abc 。如果是我的应用程序,那么我将用户存储在我的用户数据库和/或登录。

Is it safe to send this access token to my server (using SSL), then get the user's username and ID using https://graph.facebook.com/me?access_token=abc on my server and check that the application the token belongs to is mine with https://graph.facebook.com/app?access_token=abc. If it is my application I then store the user in my user's database and/or log them in.

这个系统可以被愚弄吗?你可以想象某人可以像别人一样登录吗?

Can this system be fooled? Can you think of a way someone could log in as someone else?

推荐答案

你应该查看所有的验证文档和Oauth规范,以查看不同的验证流可用

You should check out all of the Authentication documentation and the Oauth spec to see the different auth flows available

广义而言,您可以根据访问令牌在您的服务器上创建一个用户,并且可以肯定地说,当您从Facebook获取与该用户相同的用户ID的访问令牌时。

Broadly speaking, you can create a user on your server based on the access token, and be reasonably certain that when you get an access token from Facebook for the same user ID that it's the same person.

如果您对应用程序的安全性要求很高,您可以采取措施确保用户的访问令牌不是通过恶意软件或Facebook用户被欺骗而产生的,示例中显示了对CSRF的保护服务器端验证文档,还有一个重新认证您可以使用的流程

If you require very high security for the app you can take steps to ensure the user's access token wasn't produced via malware or the Facebook user being tricked, there's an example showing protection against CSRF in the Server Side Authentication documentation, and there's also a reauthentication flow you can use

这篇关于使用Facebook访问令牌是一种验证用户的安全方式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆