Rails API using Devise for authenticaion - ruby-on-rails

I set up a rails API and I am using devise for the user auth and the front end is all done in Angular. What is the best way to manage state between calls when using Devise with just an API?

Here are some open-source projects that may help you:
https://github.com/lynndylanhurley/devise_token_auth
https://github.com/cloudspace/angular_devise

Related

How to create a user authentication using rails as backend and ember as frontend

I'm working on eCommerce for my internship project. But I don't know how to create the user authentication using rails and ember
First I assume the following things:
You are using ember to develop your frontend and will consume APIs from the backend.
You are using rails to create the necessary API.
If you want to authenticate users before using your API, check out the doorkeeper and devise gem. Devise takes care of things like storing your user details in the database, resetting the password, etc. The Doorkeeper gem is used to provide authentication and authorization to APIs.
Doorkeeper Link: https://github.com/doorkeeper-gem/doorkeeper
Devise Link: https://github.com/heartcombo/devise

How to access WP REST API via OAuth by using Rails

I can't figure out how to access Wordpress via REST API with OAuth.
My App is made by Ruby on Rails. So I'd like to use RoR 5.1.
My objective is to get all post from the api.
As far as I check, no appropriate gem is there.
Anyone help please.
In Rails the common gem to deal with OAuth is OmniAuth.
1) If you did your authentication system based on Devise then you have an easy way to add OAuth to your app.
Here a good example to connect to Facebook API with Devise:
https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
Here the gem to connect with WordPress:
https://github.com/jwickard/omniauth-wordpress-oauth2-plugin
2) If you didn't your authentication system with Devise then check the OmniAuth documentation to add it to your app:
https://github.com/omniauth/omniauth
And of course you will use the WordPress gem to add the strategy as well.

Is it possible to use Devise gem / engine for hosted multisite setup?

I currently use authlogic for my Rails-hosted multi-site application by using the authenticates_many :user_sessions method on my Site model.
I want to change over to Devise. Does anyone know if this is possible and if so, how?
Thanks a lot,
Richard
There was a great post on Devise and Omniauth with SSO by Josh Software.

Rails 3 - Use only OpenID authentication

I want to add authentication to my Ruby on Rails 3 app, but I only need users to be able to authenticate using their Google accounts, because I'm making it a hosted app for the Chrome Webstore, so I think OpenID would work well for this. I want to have some custom fields in the user database to store user-specific data. What should I use for this? I want users to be able to sign up only with OpenID.
Thanks.
You should try omniauth gem, it uses not only Google OpenID. Omniauth takes user's data from provider and pass to your application which is you can amplify
I've been using authlogic and authlogic-oid add-on to handle this.
You could try the devise_openid_authenticatable gem. I haven't used it myself but it looks like it would do what you want using the Devise authentication gem, which is what I use on all of my Rails projects.

User auth example in Rails 3, using Devise, OmniAuth, Mongoid, and JSON responses

I have integrated Devise and OmniAuth with my Mongoid ORM setup using the following examples:
https://github.com/plataformatec/devise/wiki/Example-Applications
My client code is mostly JavaScript (ExtJS) and relies on JSON for all of the communication. I use no Rails templates. I am looking to build a multi-provider authentication model, primarily using user/pass, Facebook, and Twitter. I am having difficulty putting together the full User authentication flow with respect to my application stack.
I am looking for an example that uses JSON responses to the standard authentication actions, instead of redirects, and provides an integration with OmniAuth that uses Mongoid. In addition to the above examples, I have gone through Ryan Bates' Railscasts on Devise and OmniAuth. Every example I have worked through so far have either been ActiveRecord, or Rails template oriented. Any pointers are appreciated!
This (https://github.com/fertapric/rails3-mongoid-devise-omniauth) is a good example app for getting set up with rails 3, devise, omniauth and mongoid, and a tutorial to go along with it here: https://github.com/fortuity/rails3-mongoid-devise/wiki/Tutorial-(Walkthrough)
Then you'll need to override the user sessions controller to provide the correct json responses for your app, there is a good example here: https://gist.github.com/733647 and here: http://groups.google.com/group/plataformatec-devise/browse_thread/thread/daa3332b3c4a1b4b
Hope this helps
I would suggest that you roll your own authentication mechanism using Rails 3.1 ActiveModel::SecurePassword instead of using Devise. You will get a cleaner solution that way than trying to tweak Devise to provide JSON responses.
If you can't use Rails 3.1, I would still suggest that you roll your own instead of overriding an internal Devise method (which the gist that Nesbitt links to does).

Resources