FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...

Socialite

v1.3.3 Public

Socialite

A cool module to handle oauth2 authentication.

Currently support:

  • Facebook
  • Google
  • Linkedin
  • Github

Installation:

You can install with commandbox

install socialite

Otherwise download from forgebox

http://www.coldbox.org/forgebox/view/Socialite

Configuration:

You need to put your clientId, clientSecret and redirect url in config file. You can insert your data in ColdBox.cfc:

		// Custom Settings
	    moduleSettings = {
			socialite = {
				facebook = {
					client_id = "XXXXXXXXXXXXX",
					client_secret = "XXXXXXXXXXXXX",
					redirect_url = "http://YOUR-URL/provider/response/facebook"					
				},
				google = {
					client_id = "XXXXXXXXXXXXX",
					client_secret = "XXXXXXXXXXXXX",
					redirect_url = "http://YOUR-URL/provider/response/google"					
				},
				github = {
					client_id = "XXXXXXXXXXXXX",
					client_secret = "XXXXXXXXXXXXX",
					redirect_url = "http://YOUR-URL/provider/response/github"					
				},
				linkedin = {
					client_id = "XXXXXXXXXXXXX",
					client_secret = "XXXXXXXXXXXXX",
					redirect_url = "http://YOUR-URL/provider/response/linkedin"					
				}
			}
		};

Usage:

First create routes:

		route(pattern="/provider/response/:provider", target="socialite.response");
		route(pattern="/provider/:provider", target="socialite.auth");

In your view put the code for login button:

<a href="#event.buildLink( 'provider/facebook' )#">Facebook</a>

In your handler:

socialite.init().with('facebook').redirect()

This will prompt you to authentication page. Then simply:

socialite.with('facebook').user(rc.code)

A simple example:


component {

	property name="socialite" inject="[email protected]";
    property name="credentials" inject="coldbox:modulesettings: socialite";
	property name="user" inject="[email protected]";

	function index(event,rc,prc){
		event.setView("socialite/index");
	}

	function auth(event,rc,prc){
		var social = socialite.init( credentials ).with( rc.provider );
		social.redirect();
	}

	function response(event,rc,prc){
		prc.user = socialite.init( credentials ).with(rc.provider).user(rc.code);
		event.setView("socialite/index");
	}

}

And you will get user data.

Here are all the versions for this package. Please note that you can leverage CommandBox package versioning to install any package you like. Please refer to our managing package version guide for more information.

Version Created Last Update Published By Stable Actions
Current
1.3.3 Jun 05 2017 09:13 AM Jul 06 2018 09:55 AM
Version History
1.3.2 Jun 05 2017 06:30 AM Jun 05 2017 06:30 AM
1.3.1 Jun 05 2017 06:07 AM Jun 05 2017 06:07 AM
1.3.0 Jun 05 2017 01:58 AM Jun 05 2017 01:58 AM
1.2.0 Mar 24 2017 11:33 PM Mar 24 2017 11:33 PM
1.1.0 Jan 10 2017 06:29 PM Jan 10 2017 06:29 PM

 

No collaborators yet.
     
  • Jan 10 2017 06:29 PM
  • Jul 06 2018 09:55 AM
  • 926
  • 253
  • 67