grape-devise
grape-devise copied to clipboard
Devise integration gem for Grape API framework
Grape::Devise
This gem attempts to integrate Devise into Grape in native Grape fashion.
Devise has great model modules, warden strategies etc so it's really tempts to use it when building APIs.
However devise controller layer doesn't fit well with Grape. Here where grape-devise comes to the rescue.
Gem benifits:
- native Grape integration
- ready-to-use set of helpers as well-known
current_user
Installation
Add this line to your application's Gemfile:
gem 'grape-devise'
And then execute:
$ bundle
Or install it yourself as:
$ gem install grape-devise
Usage
- First of all you need to setup devise as usual. See ( https://github.com/plataformatec/devise#getting-started )
- Add
Grape::Devise::Helpershelpers and includeGrape::Devise::Endpointsmodule into your API endpoints class e.g.
class MyApi < Grape::API
helpers Grape::Devise::Helpers
include Grape::Devise::Endpoints
end
- Remove Devise routes from
routes.rbfile. We will use Grape-styled endpoints for our API, not default Rails routes. - Add
Devise.add_mapping(:users, {})to yourdevise.rbinitializer. Consider replacing:userswith appropriate symbol of your devise resource. - Restart your server
TODO
- Add support for every Devise module. Currently we have endpoints only for
:database_authenticatable - Create Rails generator
- Improve test coverage
Contributing
- Fork it ( https://github.com/pluff/grape-devise/fork )
- 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 a new Pull Request