Using rails as the omniauth provider - ruby-on-rails

I'm not entirely sure what to google. It seems everything I have googled just show me links to how to leverage omniauth to authenticate with other sites(facebook, twitter, github etc etc). That's simple and easy. What I want is the how to build that feature in a rails app, the functionalities that those sites (facebook, twitter, github) have that allow third party auth.
Here's the feature I'd like to build:
I have two separate applications, applications A and B. Let's say application A is the rails app that I want providing the authentication. And application B is using omniauth to login through application A.
How do I get started building that feature for application A?
Now, that's a loaded question, but if anyone could point to a resource I could start with that would be amazing! Thanks.

Related

Rails Single Sign On

I'm kinda stuck right now with how to use single sign on in a specific scenario. So what I need to have is the following:
Apple Id like SSO (using rails)
Multiple rails api apps with seperate react frontends
Ability to activate/deactivate access to the apps
I've been using the doorkeeper gem so far but I don't know how to limit (activate/deactivate) access to the applications.
Hope somebody can help me out!

Implement OAuth provider in Rails for use with a single client application

I'm working on building a closed community forum for members of an existing site I also built. I'd like to allow members to sign in to the new forum using their existing accounts on the main application. The forum will be on a different domain from the main site.
This will be my first time using OAuth. Most information on the web about it seems to skew heavily toward allowing users to sign in with Twitter/Facebook/etc accounts, and there's very little information that seems pertinent to what I'm working on.
I'd like to create an OAuth provider in the original web app and a OAuth client in the new app I'm building. No other providers will be used, and no other client sites will be authenticating off this main site. Additionally, I need to avoid any sort of "authorize this web site" intermediary step for my users.
The main site is Rails 4 with Devise, and the new site is Rails 5. I'd like to stick with Devise on the new site as well, which I understand can function as an OAuth client. Doorkeeper seems like it could be overkill for my exceedingly simple needs, but most other information I've found is years out of date, so I don't want to invest time pursuing an implementation that won't work or is not the current best approach.
What is currently the best way to handle this kind of single-client, single-provider setup?

Angular/Ionic/Phonegap app with rails API web service Auth

I have recently decided to experiment with Angular/Ionic/Phonegap with a Rails API Web Service as backend, to create my first mobile app.
I am from a Rails background and usually use Devise to handle my user authentication/User object to which I assign Roles using Rolify.
Doing some reading, it seems to me that this is not the same methodology that I would have to follow for a mobile app as seen in this question? What I would ideally like to have, is for users to sign in / up using their Facebook accounts, which would create their User record. My web service will then assign the required roles etc.
So my question:
Should I be using Devise/Rolify/Pundit ?
Is there a better/more efficient way to handle this process using this stack?
Thanks
You can use Devise with the omniauth-facebook gem. There are some nice articles out there on how to implement.
Along with this question you should hopefully be able to work it out.
Any backend auth service should really work fine. We use Devise and have found it to work well with angular and ionic. We recently wrote a tutorial on how to set up Ionic with Devise that you might find useful.

Use the same users with Rails (Devise) and Drupal 7

I have an app made with Rails 4. I want to add a blog made with Drupal 7. It hasn't been in production yet so no users are stored. I want the users to be able to comment in Drupal 7 with the same email / password (and ideally sessions) that with Rails 4. From my point of view, maybe the solution may come from setting the table that Devise uses to the one Drupal creates, and then copying the encryption salt of the Drupal installation, or maybe using the same OAuth login for both sites, like Google or Facebook, but I would need specific registration for this app.
I know there is a similiar question: Import Drupal user accounts into Rails without requiring users change their passwords but in my case I the users to work both ways.
Any ideas would be appreciated, thanks.
I would go for a clean solution. Whatever login feature you have in rails ( be it implemented by hand, devise or any other), allow it to login users using a GET request (i.e. Embedding the authentication details in the url). This way, you will be using the Rails application as an API for the blog and you will not have to expose the user credentials.

Authenticating Web and Mobile to Rails API

I am reading the Service Oriented Design with Ruby book by Paul Dix and many posts here but am left with many questions surrounding authenticating users and the application.
I want to have api.site.com as a RESTful Rails app serving up JSON. Secure.site.com will be a web app (maybe Rails or maybe PHP) that will consume the service. Also a mobile app such as iPad will also consume it.
So is the first step to build in a level of auth so that only my web app and mobile app can consume the service? Then once the calling app has been authenticated, both these apps will have users who want to CRUD their data so then authenticate them as well?
I've read about Http basic, digest, tokens, oauth and many plugins but am having a difficult time narrowing down the most flexible and reusable way. For now this is simply learning so I would like to stay away from plugins so I can learn the code better.
Can my web app use normal sessions like I'm familiar with and then the mobile use their equivalent to sessions. At that point I still have no authenticated the calling app though. Http basic seemed like I could use it from both, but I didn't see a way for my web app to use a normal login form and logging out seemed like an issue.
I would suggest two solutions for you.
Use a Gem like devise for login system and inherit the devise registration and sessions controller to make it respond to JSON requests.
Create your own simple authentication and use respond to HTML and respond to JSON for separating web and mobile login
Iam not totally sure whether a mobile device maintains a session (please look around) but u can always use a token authentication system if it doesnt.

Resources