https://github.com/kenfehling/omniauth-stateless
Ruby gem for doing stateless authentication with omniauth
https://github.com/kenfehling/omniauth-stateless
api jwt middleware omniauth rails rest ruby stateless
Last synced: about 1 month ago
JSON representation
Ruby gem for doing stateless authentication with omniauth
- Host: GitHub
- URL: https://github.com/kenfehling/omniauth-stateless
- Owner: kenfehling
- License: mit
- Created: 2014-09-27T21:07:40.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-29T00:47:51.000Z (over 11 years ago)
- Last Synced: 2024-04-17T04:19:09.023Z (about 2 years ago)
- Topics: api, jwt, middleware, omniauth, rails, rest, ruby, stateless
- Language: Ruby
- Homepage:
- Size: 148 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# omniauth-stateless
Helps [OmniAuth](https://github.com/intridea/omniauth)
to be used in a stateless manner (e.g. with REST APIs)
by authenticating during each request.
## Use case
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.
## Confirmed to work with these OmniAuth strategies
* [omniauth-facebook-access-token](http://github.com/kenfehling/omniauth-facebook-access-token)
* [omniauth-identity](https://github.com/intridea/omniauth-identity)
## Installation
Add this line to your application's Gemfile:
gem 'omniauth-stateless'
And then execute:
$ bundle
Or install it yourself as:
$ gem install omniauth-stateless
## Usage
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=facebook_access_token&access_token=abcdefghijklmnop
> http://example.t.proxylocal.com/api/items?provider=identity&auth_key=email&password=password
## 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