|
1 | 1 | # OmbuLabs::Auth
|
2 |
| -Short description and motivation. |
| 2 | +> _Refactor a rack middleware (probably a ruby gem) out of https://points.ombulabs.com/ so that we can easily add GitHub-based authentication to other Ruby/Rails internal applications._ |
| 3 | +> |
| 4 | +> _It would be useful if we could add it to http://skunk.fastruby.io (backend for skunk) so that anybody who is part of our organization could sign in and review details in the admin panel._ |
| 5 | +> |
| 6 | +> _Said gem should be easily configurable (only with environment variables) and should make it very simple to add "OmbuLabs-authentication" to our internal Ruby apps._ |
3 | 7 |
|
4 |
| -## Usage |
5 |
| -How to use my plugin. |
| 8 | +## Configs |
| 9 | +Make sure you configure your ENV variables to use Github authentication. |
6 | 10 |
|
| 11 | +``` |
| 12 | +ENV["GITHUB_APP_ID"] |
| 13 | +ENV["GITHUB_APP_SECRET"] |
| 14 | +ENV["ORGANIZATION_LOGIN"] |
| 15 | +``` |
7 | 16 | ## Installation
|
8 |
| -Add this line to your application's Gemfile: |
| 17 | + |
| 18 | +- Clone this gem inside the `lib` folder of your project |
| 19 | + |
| 20 | + |
| 21 | +- Add these lines to your application's Gemfile: |
9 | 22 |
|
10 | 23 | ```ruby
|
11 |
| -gem "ombu_labs-auth" |
| 24 | +gem 'ombu_labs-auth', path: 'lib/ombu_labs-auth' |
| 25 | +gem 'omniauth-github', '~> 2.0.0' |
12 | 26 | ```
|
13 | 27 |
|
14 |
| -And then execute: |
| 28 | +- And then execute: |
15 | 29 | ```bash
|
16 | 30 | $ bundle
|
17 | 31 | ```
|
18 | 32 |
|
19 |
| -Or install it yourself as: |
20 |
| -```bash |
21 |
| -$ gem install ombu_labs-auth |
| 33 | +- Add the following line to `config/routes.rb` |
| 34 | + |
| 35 | +```ruby |
| 36 | +mount OmbuLabs::Auth::Engine, at: '/', as: 'ombu_labs_auth' |
| 37 | +``` |
| 38 | + |
| 39 | +- Add a Devise signin link in your homepage (notice all URL helpers will be under the engine object `ombu_labs_auth`) |
| 40 | + |
| 41 | +```html |
| 42 | +<div> |
| 43 | + <h1>Welcome to the App</h1> |
| 44 | + <%= link_to "Sign in", ombu_labs_auth.new_user_session_path %> |
| 45 | +</div> |
| 46 | +``` |
| 47 | + |
| 48 | +- Add the Devise authentication helper to your private objects controllers |
| 49 | + |
22 | 50 | ```
|
| 51 | +before_action :authenticate_user! |
| 52 | +``` |
| 53 | + |
| 54 | +## Usage |
| 55 | +_TODO_ |
| 56 | + |
| 57 | +## Caveats |
| 58 | + |
| 59 | +Please be aware this gem is a mountable engine which depends on Devise, and it's not possible to mount it multiple times. Refer to their Wiki for more on the issue - https://github.com/heartcombo/devise/wiki/How-To:-Use-devise-inside-a-mountable-engine |
23 | 60 |
|
24 | 61 | ## Contributing
|
25 |
| -Contribution directions go here. |
| 62 | +_TODO_ |
26 | 63 |
|
27 | 64 | ## License
|
28 | 65 | The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
0 commit comments