Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cleanly integrate login from Facebook, Google, Twitter, etc. into CakePHP?

Summary of the question:
I would like to create a CakePHP based registration and login system offering multiple different gateways such as OpenID, Facebook, Twitter, and so forth. I would like the system to allow a user to associate multiple forms of identification with their account.

After much searching, I am turning up a blank on anything that would allow more than one method of authorization. Cake's authorization system does complicate the matter, so using a tutorial for general PHP is not really effective. Does anyone have a solution, or somewhere I can start from?

Example:
To give a simple example, looking at the StackExchange network: you can login/register using a stack exchange account, Google, Yahoo, Facebook, or OpenID. Once logged in, you can add more of these methods to your account so that you are recognized a multitude of ways. I realize StackExchange probably isn't written in Cake, but it serves as an example.

Thank you!



Original Question

Here's the scoop: I'd like to integrate a simple registration/login system for each of the main services that offer oauth/openid in CakePHP.

Basically, I'd like my users to be able to register the old fashion way (including validation e-mail) or using an existing service to verify themselves. I'd like them to be able to login afterwards using that service, or with a username and password.

Now, I have found extremely in depth plugins for full facebook integration and the like, but the bottom line is that I want to just use this for registration and login at this point, and I would like the experience to be the same regardless of which service they choose (plus, I'd like to understand how it works... because this is all about learning CakePHP after all).

I'd also like them to be able to link other services once the account is created if they so desire. In a nut shell, they're account should be able to be linked to any number of login services, or none at all.

How on earth do I go about this?

Thank you,

James

like image 527
xtraorange Avatar asked May 03 '12 22:05

xtraorange


2 Answers

Looks like there is now a third-party library available using Opauth as detailed on this bakery thread

Here is the CakePHP version's github page:

https://github.com/uzyn/cakephp-opauth

like image 159
AngeloS Avatar answered Oct 20 '22 07:10

AngeloS


Great question - our CakePHP development studio may be looking at this in the coming months also. I suspect you'll have more luck researching this as a general PHP question and then how you can port that solution into Cake. Definitely post back with anything you discover.

You might find this thread a helpful starting point, although it was posted back in 2010:

  • Best way to implement Single-Sign-On with all major providers?
like image 45
Simon East Avatar answered Oct 20 '22 08:10

Simon East