热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用openid-selector实现没有第三方的社交登录-ImplementingSocialLoginwithoutthirdparty,usingopenid-selector

Ivelookedatroughly50questionsonthissite,butnonereallyprovideasolutionthatiseither

I've looked at roughly 50 questions on this site, but none really provide a solution that is either up to date or doesn't require a third part pluggin (I want to keep control of the information and not give other people access to the info I get) or that is complete. I'll take the risk of posting it, and cross my fingers.

我在本网站上查看了大约50个问题,但没有一个真正提供最新的解决方案或者不需要第三部分插件(我想保持对信息的控制而不是让其他人访问我得到的信息)或那是完整的。我会冒着发布它的风险,然后交叉我的手指。

I've seen a bunch more but here are some I looked at:

我已经看到了更多,但这里有一些我看过:

  • include facebook and twitter as login option (all answers are third party solutions)
  • 包括facebook和twitter作为登录选项(所有答案都是第三方解决方案)

  • https://stackoverflow.com/questions/76184/php-tutorial-for-openid-and-oauth (3yeras old, there must be easier implementation)
  • https://stackoverflow.com/questions/76184/php-tutorial-for-openid-and-oauth(3岁,必须更容易实现)

  • http://wiki.openid.net/w/page/12995176/Libraries => this looks good, but I'm still confused.
  • http://wiki.openid.net/w/page/12995176/Libraries =>这看起来不错,但我仍然很困惑。

So I'm looking to have Facebook, Google and Twitter as login options on my site (Apparently, that is 80% of peoples preferred social login method).
If I go to the wiki.openid.net, which package would you advise me to use in PHP for easy implementation? Which one did you use in the past?

因此,我希望将Facebook,Google和Twitter作为我网站上的登录选项(显然,这是人们首选的社交登录方式的80%)。如果我去wiki.openid.net,你会建议我使用哪个软件包来轻松实现?你过去使用过哪一个?

Also, if possible, can you give explanations on how to implement the advised library? ie,

另外,如果可能的话,您能解释一下如何实施建议的库吗?即

  1. I download it, put it on my site,
  2. 我下载它,把它放在我的网站上,

  3. then get an openID for my site,
  4. 然后获取我的网站的openID,

  5. then use the the http://code.google.com/p/openid-selector/ for the display...
  6. 然后使用http://code.google.com/p/openid-selector/进行显示...

Is this right? I have no idea...

这是正确的吗?我不知道...

Basically a step by step guide would be awesome. I'm sure anyone who takes time to answer this will get massive points, this is hot topic.

基本上一步一步的指南会很棒。我敢肯定,任何花时间回答这个问题的人都会获得大量积分,这是热门话题。

Thanks for the help.

谢谢您的帮助。

3 个解决方案

#1


11  

So you want to implement Google and Facebook/Twitter login, without using a third party service. That means you need to implement OpenID login (for Google) and OAuth (for Facebook/Twitter).

因此,您希望在不使用第三方服务的情况下实施Google和Facebook / Twitter登录。这意味着您需要实施OpenID登录(针对Google)和OAuth(针对Facebook / Twitter)。

First OpenID. You can download LightOpenID a nice lightweight OpenID class for PHP. Quite easy to implement. Some samplecode how to use this class.

第一个OpenID。您可以为Light下载LightOpenID一个很好的轻量级OpenID类。很容易实现。一些samplecode如何使用这个类。

// Set up your OpenID object
$openid = new LightOpenID('http://yourdomain.com');
$openid->returnUrl = 'http://yourdomain.com/after/login/user/goes/here';
$openid->identity = 'https://www.google.com/accounts/o8/id'; // OpenID provider URL
$openid->required = array('namePerson/friendly', 'contact/email');

// Step 1: Redirect the user to the OpenID provider
if (!$openid->mode) // If not authenticated
    header('Location: ' . $openid->authUrl()); // Redirect to provider

// Step 2: User returned, sign the user into our application
if ($openid->validate()) { 
    // OpenID authentication is successful
    // Sign in the user and read requested attributes
    $attrArray = $openid->getAttributes();
}

That should get you started with the OpenID part. The OpenID selector is nothing more then a selector for the identity URL.

这应该让你开始使用OpenID部分。 OpenID选择器只不过是身份URL的选择器。

Then implementing OAuth sign in to support Facebook and Twitter sign in. There is quite some documentation on how to implement Facebook and Twitter login support. For Facebook you should read the developer site on authentication it's not too complicated. Twitter uses the same protocol and also has quite nice documentation on this topic.

然后实施OAuth登录以支持Facebook和Twitter登录。有一些关于如何实现Facebook和Twitter登录支持的文档。对于Facebook,你应该阅读开发者网站的认证,这不是太复杂。 Twitter使用相同的协议,并且在此主题上也有相当不错的文档。

If you don't want to implement it yourself take a look at OAuth libraries that you can include in your application like socialoauth (supports both) or twitteroauth (supports twitter). Google will help you find a lot more libraries like this.

如果您不想自己实现它,请查看您可以在应用程序中包含的OAuth库,例如socialoauth(支持两者)或twitteroauth(支持twitter)。谷歌将帮助您找到更多这样的图书馆。

Just start implementing with a library read the code, comments and docs and ask questions on StackOverflow if your stuck. :)

刚开始使用库实现读取代码,注释和文档,并在StackOverflow上提问如果卡住了。 :)

#2


0  

This HybirdAuth seems even more cool:

这个HybirdAuth看起来更酷:

Do check out: http://hybridauth.sourceforge.net/

请查看:http://hybridauth.sourceforge.net/

Licensed both as GPL and MIT. Do share if any of you know anything better.

获得GPL和MIT许可。如果你们中的任何人知道更好的话,请分享。

#3


0  

Hey also check this Social Login provider OneAll. Its awesome and easy to use. Supports many providers. Here's the link http://www.oneall.com/

嘿还检查这个社交登录提供商OneAll。它很棒,易于使用。支持许多提供商。这是链接http://www.oneall.com/


推荐阅读
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • 基于PgpoolII的PostgreSQL集群安装与配置教程
    本文介绍了基于PgpoolII的PostgreSQL集群的安装与配置教程。Pgpool-II是一个位于PostgreSQL服务器和PostgreSQL数据库客户端之间的中间件,提供了连接池、复制、负载均衡、缓存、看门狗、限制链接等功能,可以用于搭建高可用的PostgreSQL集群。文章详细介绍了通过yum安装Pgpool-II的步骤,并提供了相关的官方参考地址。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • 本文介绍了开关稳压器设计中PCB布局布线的重要性,并提供了相应的准则。开关稳压器作为一种高效的电源,逐渐取代了线性稳压器。开关模式电源的工作原理是通过一定的开启时间和关闭时间来实现电压转换。开关频率并不是影响系统的最大因素,而开关转换的速度才是关键。在系统噪声方面,开关频率或其谐波可能会对系统产生影响。严格遵守PCB布局布线的准则,可以将开关模式电源的相关问题降到最小。 ... [详细]
  • 本文介绍了P1651题目的描述和要求,以及计算能搭建的塔的最大高度的方法。通过动态规划和状压技术,将问题转化为求解差值的问题,并定义了相应的状态。最终得出了计算最大高度的解法。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • 本文介绍了Windows操作系统的版本及其特点,包括Windows 7系统的6个版本:Starter、Home Basic、Home Premium、Professional、Enterprise、Ultimate。Windows操作系统是微软公司研发的一套操作系统,具有人机操作性优异、支持的应用软件较多、对硬件支持良好等优点。Windows 7 Starter是功能最少的版本,缺乏Aero特效功能,没有64位支持,最初设计不能同时运行三个以上应用程序。 ... [详细]
author-avatar
小豇豆和花椰菜
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有