Facebook的身份验证实施 [英] Facebook Authentication Implementation

查看:159
本文介绍了Facebook的身份验证实施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作,这将完全使用Facebook的身份验证(没有自定义验证实现存在)的项目。项目采用PHP的服务器端脚本。我环顾四周,实现快速,安全的认证机制,但我不能找到有关这个问题的任何详细说明。 Facebook的文件是软弱和不只能提供基本信息。

I'm working on a project which will use facebook authentication completely (no custom authentication implementation exists). Project uses PHP for server-side scripting. I looked around for implementing fast and secure authentication mechanism but i cannot find any detailed description about this subject. Facebook's documents are weak and does only provide basic information.

哪种身份验证方法将是适当的?有一个Javascript SDK和PHP SDK。据我了解,我必须使用JavaScript SDK进行登录,然后使用PHP SDK我会检查我的数据库来验证凭据。但使用的PHP SDK图形API是缓慢的。有没有更好的办法来验证会话?

Which authentication method would be appropriate? There's a Javascript SDK and PHP SDK. As i understand, i have to use Javascript SDK for login, then using PHP SDK i will check my database for verifying credentials. But using Graph API with PHP SDK is slow. Is there a better way to validate session?

我将需要在每次请求检查会议服务器端(PHP-SDK)?

Will i need to check session server-side (PHP-SDK) on every request?

推荐答案

我到底是什么了做我的应用程序进行比较,我见过的任何其他方法pretty简单,比较快的。

What I end up doing for my apps is pretty simple and relatively fast compared to any other method I've seen.


  1. 检查是否存在signed_request,解析它,如果它。如果没有,PHP中的$登录标志设置为1

  2. 我检查用户的会话/ cookie来看看用户是$ P $由应用(pviously验证后会回到这一点。如果是空的,设置$登录1。

  3. 如果登录标志被设置为1,发送用户到安装网址。

  4. 用户安装应用程序,并发送到连接器的页面。该页面提供一个获取和的access_token生成用户会话/ cookie的目的。这意味着你将不太可能需要检查这个的access_token的有效性为用户的会话生命周期。 offline_access也创造了新的机遇。你可以存储在你的分贝的access_token为好。

  5. 只要你有一个电话说出去的Facebook,检查异常,如果你打一个身份验证例外,清除用户的会话和饼干。下一次,这将迫使他们更新的access_token,哪怕这个过程是用户看不到的。

我这样做对我的应用程序,在多数情况下意味着我不必做查询FB看到的access_token的有效性,也做我必须不断地得到它在每个页面视图。我们的目标是减少对我们的应用程序延迟,但Facebook是延迟的最大来源,这样做已经削减下来增色不少。

I've done this on my apps, in most cases means I don't have to make queries to FB to see the validity of the access_token nor do I have to constantly get it on each page view. Our goal was to reduce latency on our apps, but Facebook was the biggest source of latency, doing this has cut it down considerably.

这篇关于Facebook的身份验证实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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