Skip to content
vic

jsmestad/socialite

Support (and manage) Authentication with multiple OmniAuth providers in your Rails application

jsmestad/socialite.json
{
"createdAt": "2011-09-14T19:58:54Z",
"defaultBranch": "master",
"description": "Support (and manage) Authentication with multiple OmniAuth providers in your Rails application",
"fullName": "jsmestad/socialite",
"homepage": "https://github.com/jsmestad/socialite",
"language": "Ruby",
"name": "socialite",
"pushedAt": "2013-10-30T18:31:06Z",
"stargazersCount": 58,
"topics": [
"authentication",
"engine",
"oauth2",
"omniauth",
"rails"
],
"updatedAt": "2024-01-27T00:58:07Z",
"url": "https://github.com/jsmestad/socialite"
}

up (optional)

Socialite.setup({ /* settings */ });

setup allows you to specify settings for each network such as localisation (see below for all options).

Socialite.setup({
facebook: {
lang : 'en_GB',
appId : 123456789,
onlike : function(url) { /* ... */ },
onunlike : function(url) { /* ... */ },
onsend : function(url) { /* ... */ }
}
});

See Facebook’s documentation on Internationalization for supported language codes.

Socialite.setup({
twitter: {
lang : 'en',
onclick : function(e) { /* ... */ },
ontweet : function(e) { /* ... */ },
onretweet : function(e) { /* ... */ },
onfavorite : function(e) { /* ... */ },
onfollow : function(e) { /* ... */ }
}
});

See Twitter’s documentation for support on Web Intents Javascript Events and supported Languages.

Twitter share buttons can override the global language setting with a data-lang attribute.

Socialite.setup({
googleplus: {
lang : 'en-GB',
onstartinteraction : function(el, e) { /* ... */ },
onendinteraction : function(el, e) { /* ... */ },
callback : function(el, e) { /* ... */ }
}
});

See Google’s documentation for support on Events and Languages.

Send me feedback and testing issues!

The main core of Socialite is built for extensibility. It’s basically a fancy script loader designed for social widgets. They can be stripped out easily if not used and new ones added:

Socialite.network('network', params);
Socialite.widget('network', 'widget', params);

With these two functions you can add extended support. See the source code for examples (more guides to come here). I’m always working on support and settings for more networks, check back frequently!

Tom Morton @tmort has also created a WordPress plugin that packages WPSocialite and makes it a one step installation into your WordPress powered website. Download it from here: http://wordpress.org/plugins/wpsocialite/.

  • added GitHub Buttons extension
  • Google+ window.gapi.render() now used on inner gplus div to avoid inline styles on the socialite element
  • added Google+ googleplus-badge widget
  • added a Buffer App extension
  • created an extensions folder in the repository
  • Pinterest and Spotify removed from the default socialite.js and socialite.min.js builds.

This is an opinionated Rails 3.1 mountable engine provides your application with support for managing multiple OAuth providers per User.

Every site I have built in the past couple years has required implementing authentication support for Users. Now this was simple enough when it was only one provider (in my case, “Login with Facebook”), but more often then not it evolved into “Login with <insert_oauth_provider>”.

Now OmniAuth has some good write-ups on handling multiple providers, but it lacked any support for restricting a user to one identity per provider. Socialite aims to solve this and while enforcing every user to have a Basic Authentication identity as a fall-back in case of password recovery.

  1. Every User can only have one identity per supported provider
  • Example: User can have only 1 linked Facebook Identity at any given time
  1. Every User must have an basic-auth identity
  • Example: User signs up through Facebook, but unlinks it. Enforcing a local basic auth mechanism aids account recovery.
  1. Supports any provider strategy in the OmniAuth project.

To use Socialite in a Rails 3.1 application:

  • Require it in the Gemfile: gem 'socialite', git: 'git://github.com/jsmestad/socialite
  • Install the gem it by running bundle install.
  • Run the socialite generator using rails g socialite:install for typical installs and rails g active_record:socialite for specifying custom options.

This project began as a fork of Tim Riley’s great Omnisocial plugin. The motivation for this fork is that I required multiple authorizations for each account (linking support) and wanted a proper mountable Rails 3.1 Engine.

Socialite is Copyright (c) 2011- 2013 Justin Smestad. All Rights are Reserved. Code is distributed under the Apache 2.0 License. See LICENSE file for more information.

The original OmniSocial code is Copyright (c) 2010-2011 Tim Riley and Icelab, and is released under MIT License.