Helps OmniAuth to be used in a stateless manner (e.g. with REST APIs) by authenticating during each request.
A REST API contains resources that require authentication through Facebook Single Sign-On on Android or iOS.
Normally OmniAuth works by intercepting requests for certain paths (/auth/:provider/...) that are used for logging in and out. For stateless applications we essentially wish to log in during each request. This gem provides Rack middleware for authenticating on every request where credentials are provided.
Add this line to your application's Gemfile:
gem 'omniauth-stateless'
And then execute:
$ bundle
Or install it yourself as:
$ gem install omniauth-stateless
Set up omniauth as normal.
Add this to config/application.rb
Rails.application.config.middleware.use OmniAuth::Stateless::Builder
Add this to config/routes.rb
mount OmniAuth::Stateless::Engine => '/'
Create your controller like this
class Api::ItemsController < OmniAuth::Stateless::BaseController
before_action :require_auth, only: [:create]
respond_to :json
def create
...
end
end
Connect from your client like this
http://example.t.proxylocal.com/api/items?provider=identity&auth_key=email&password=password
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new pull request