CloudhdrAuth

Setup the Gemfile

gem 'cloudhdr_auth', :git => 'need to figure out the private gem thing'

Setup config/environment.rb to load constants

Add this just before MyApp::Application.initialize!

Dir.glob( "config/constants/*" ).each do |file|
  Kernel.const_set File.basename(file, ".yml").upcase, YAML::load_file(File.join(Rails.root, file))[Rails.env]
end

require 'omniauth/strategies/cloudhdr'

Create the auth_provider.yml constant file

Put this in config/constants/auth_provider.yml

Alter the URL as needed, and make sure that the app_id and app_secret are registerd with the provider located at the URL. It's best to have a unique id and secret for each app and env.

development:
  url: http://localhost:3000
  app_id: testid
  app_secret: testsecret
test:
staging:
production:

Create an omniauth.rb initializer

Put this in config/initializers/omniauth.rb

# Change this omniauth configuration to point to your registered provider
# Since this is a registered application, add the app id and secret here
APP_ID = AUTH_PROVIDER['app_id']
APP_SECRET = AUTH_PROVIDER['app_secret']

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :cloudhdr, APP_ID, APP_SECRET
end

Create a User model

The User model should use binary for the id

    create_table :users, :id => false do |t|
      t.binary :id, :primary => true, :null => false
      t.timestamps
    end
    add_index :users, :id, :unique => true

Update ApplicationController

The first line should look like this

class ApplicationController < CloudhdrAuth::BaseController

Protect some stuff

before_action :login_required