Devise Remote Client provides basical tools to allow your to manage devise users inside of a client Rails application, with a custom backend server.
This is mostly useful to manage authentication and other aspects of devise's user management with a web service as the backend, but all the remote communication is let to your to implement.
This means that there are no assumptions on the way your client app communcates with your backend, and you'll be able to customize it to your needs.
Add this line to your application's Gemfile:
gem 'devise_remote_client'And then execute:
bundleOr install it yourself as:
gem install devise_remote_clientYou'll certainly be using a PORO, or ActiveModel::Model object for defining
your devise model.
For devise to work with your object, you'll need to include the following in your model :
class User
extend ActiveModel::Callbacks
extend Devise::Models
define_model_callbacks :validation
endAllows to authenticate your user remotely with a custom callback.
Add the :remote_authenticable module to your devise model :
class User
extend ActiveModel::Callbacks
extend Devise::Models
define_model_callbacks :validation
devise :remote_authenticatable
attr_accessor :id, :authentication_token
endNow, configure the authentication_method callback method in your devise.rb
initializer like the following :
config.remote_authenticatable.authentication_method do |authentication_hash|
# authentication_hash contains :email and :password keys to allow your
# to call your backend and return an object that respond to `#id` and
# `#authentication_token`
endYou should now be able to sign your users in with the usual session routes.
- Fork it ( https://github.com/glyph-fr/devise_remote_client/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