Devbootcamp

Common code among internal devbootcamp apps

Installation

Add this line to your application's Gemfile:

gem 'devbootcamp', :git => '[email protected]:Devbootcamp/devbootcamp.gem.git'

And then execute:

$ bundle

Or install it yourself as:

$ gem install devbootcamp

Rails Installation

Add the following line to your routes file to have the standard routes for sign in, sign out and callback:

# config/routes.rb
Devbootcamp::Rails.draw_routes(self)

See rake routes for more information on these routes.

To require authentication and have reference to a current user, add the following to your application controller:

# app/controllers/application_controller.rb
require 'devbootcamp/rails/authentication_concern'

class ApplicationController < ActionController::Base
  include Devbootcamp::Rails::AuthenticationConcern

  # ... your code
end

Now unauthenticated requests will be redirected your sign in path. This requires an authentication controller; create the following controller:

# app/controllers/authentication_controller.rb
require 'devbootcamp/rails/authentication_controller'

class AuthenticationController < Devbootcamp::Rails::AuthenticationController
end

Lastly, we must configure 3 environment variables and initialize the gem.

These credentials are for our staging environment

DBC_OAUTH_APPLICATION_ID=5460fdba9c987384e2514c0ca8c4b20591e808ce2f78ebdebcc9b9f811066b23
DBC_OAUTH_SECRET=45cbe6feb64f4f482b5bc0dbf1891a3b02049bf4dbfe56e2f4a947814d6cf7e9
DBC_OAUTH_SITE="https://auth-devbootcamp-com-staging.herokuapp.com"

This authenticates against our Socrates staging database. Your server must be running on localhost:5000.

Create the initializer:

# config/initializers/oauth.rb
Devbootcamp::Rails.initialize!

Contributing

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