Sha256: fff36c42633c9646bb6040abc851262184249ea93bc8c6f3f7f779d56021d783

Contents?: true

Size: 915 Bytes

Versions: 3

Compression:

Stored size: 915 Bytes

Contents

## 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
```
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```

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
proxy_auth-0.0.4 README.md
proxy_auth-0.0.3 README.md
proxy_auth-0.0.2 README.md