Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Rails Engine to provide authentication for Thincloud applications.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app
config
db/migrate
lib
script
test
.gitignore
.ruby-version
.travis.yml
Gemfile
MIT-LICENSE
README.md
Rakefile
thincloud-authentication.gemspec

README.md

Thincloud::Authentication

Build Status Code Climate

Description

A Rails Engine to provide authentication for Thincloud applications.

Requirements

This gem requires Rails 3.2+ and has been tested on the following versions:

  • 3.2

This gem has been tested against the following Ruby versions:

  • MRI 1.9.2
  • MRI 1.9.3
  • JRuby 1.6+ (with JRUBY_OPTS=--1.9)
  • Rubinius 2.0.0dev (with RBXOPT=-X19)

This gem has been tested against the following database versions:

  • MySQL 5.0, 5.5
  • PostgreSQL 9.1, 9.2
  • SQLite 3

Installation

Add this line to your application's Gemfile:

gem "thincloud-authentication"
  • Run bundle
  • Copy the migrations and prepare your databases:
$ rake thincloud_authentication:install:migrations db:migrate db:test:prepare
  • Mount the engine in your config/routes.rb file:
mount Thincloud::Authentication::Engine => "/auth", as: "auth_engine"

Using the example above, you may now login or signup at http://lvh.me:3000/auth.

Prerequisites

The following must be true for thincloud-authentication to operate properly:

  • A root_url must be defined in config/routes.rb
  • A User model must exist

Configuration

The Thincloud::Authentication module accepts a configure block with options to customize the engine behavior.

Mailers

Set the mailer_sender option to customize the "From" address of the emails sent from the system:

Thincloud::Authentication.configure do |config|
  config.mailer_sender = "app@example.com"
end

Additional provider strategies

Add a key to the providers hash with the name of the strategy, followed by additional options for scopes and fields as needed. Additionally, you will need to provide environment variables (prefixed with the provider name), with the consumer_key and consumer_secret values from your OAuth provider.

To enable the LinkedIn provider:

  • Provide values for ENV["LINKEDIN_CONSUMER_KEY"] and ENV["LINKEDIN_CONSUMER_SECRET"]
  • Add the file config/initializers/thincloud_authentication.rb with the following contents:
Thincloud::Authentication.configure do |config|
  config.providers[:linkedin] = {
    scopes: "r_emailaddress r_basicprofile",
    fields: ["id", "email-address", "first-name", "last-name", "headline",
             "industry", "picture-url", "location", "public-profile-url"]
  }
end

Vanity Routes

If you want to customize the routes (remove the /auth prefix), you may add the following to your config/routes.rb file:

get "signup", to: "thincloud/authentication/registrations#new", as: "signup"
get "login", to: "thincloud/authentication/sessions#new", as: "login"
delete "logout", to: "thincloud/authentication/sessions#destroy", as: "logout"

Using the example above, you will have the following routes locally:

  • signup_url points to "/signup"
  • login_url points to "/login"
  • logout_url points to "/logout" - Make sure to use the delete method to logout.

TODO

  • Add "forgot password" functionality
  • Add multiple, configurable strategy options
  • Add a configuration option to customize the mailers

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a Pull Request

License

Something went wrong with that request. Please try again.