Installation

  1. In your Gemfile add line gem 'proxy_auth'
  2. Run bundle install
  3. Set config/secrets.yml: #!bash proxy: token: SECRET_TOKEN url: http://HOST:PORT service: name: SERVICE_NAME url: http://SERVICE_HOST:SERVICE_PORT version: API_VERSION
  4. Initialize with command rails generate proxy_auth:install
  5. Secure your application. In file app/controllers/application_controller.rb ``` #!ruby before_action :authenticate

protected

def authenticate authenticate_token || render_unauthorized end

def authenticate_token authenticate_with_http_token do |token| ProxyAuth::Token.instance.valid? token end end

def render_unauthorized render json: 'Bad credentials', status: 401 end

6. Add management routes

!ruby

mount ProxyAuth::Engine => '/proxy'

7. Restart your Rails application.
8. Rake task for reconnecting to proxy: ```rake proxy_auth:register_service```