Rails - Wordpress SSO - Single-Sign On - ruby-on-rails

I'm trying to achieve an integration between a Rails app (the core of my website, at domain.com and www.domain.com) and a Wordpress Network (multisite, at *.domain.com).
For that I need to build a Single Sign On process.
I have found a plugin : Rails Integration Api, but i didn't find the article or readme describing the rails part. The process is based on the recuperation of the cookie, created in rails.
So my questions will be :
Do you know any pointers to achieve a Rails - Wordpress SSO integration ?
Do you know some good resources about implementing Wordpress SSO, for any backend ?
Thanks in advance.

That plugin looks like it's looking to the cookie set by your Rails app. If you look at the cookies that are set after you login to that app, do any of them jump out at you as being the auth session cookie?
Also, here's the article referenced in the plugin about configuring the Rails side: http://web.archive.org/web/20090116063054/http://greenfabric.com/page/integration_api_home_page
It looks like it's been defunct for a while (only available thru archive.org) but maybe that will help you put the puzzle together.

Here's a blog post outlining setting up Wordpress as an Oauth provider and authenticating a rails application against it. http://www.objectpartners.com/2014/02/18/single-sign-on-with-rails-wordpress-and-oauth2/

Related

Best authentication strategy for Ruby on Rails API only server (with ActiveAdmin)

I have a project where I want to develop the frontend in Next.js (requests based on fetch API from JS) and the backend in RoR and I am having a hard time to get the User authentication to work. I have researched and found four possible solutions:
Sessions and cookies
JWT
devise_token_auth
devise-jwt
I have tried to implement some of them but i always end up getting a server error on client requests at some point. I would like to know if anyone has any resources where I can get to know more about and learn more about it so I can implement such authentication in my project.
If I could take advantage of devise would be even better, since I already have it setup for ActiveAdmin (wanna use the admin dashboard)
Thanks a lot in advance.
I used to use devise, but have since moved to AWS Cognito which handles everything for you and is customizable as needed. You might look into it.
https://aws.amazon.com/cognito/

Rails 5 application: form and api authentication tutorial?

Are there any good tutorial to create an auth system from scraths with form and api authentication?
I found a lot of tutorial but unfortunately they implement only form based or only api based authentication.
But I would like to build a form and api based.
Because for the SEO the server side rendering is important so I can create a registration and login form too. But API based important for a mobile app application.
Here are some resources, that you might find useful. I have used the first one frequently in the past.
http://railscasts.com/episodes/250-authentication-from-scratch
https://gist.github.com/thebucknerlife/10090014
https://rubyplus.com/articles/4171-Authentication-from-Scratch-in-Rails-5
https://www.sitepoint.com/rails-userpassword-authentication-from-scratch-part-i/
How to create authentication from scratch in rails 4
I hope this gives you some inspiration.

Rails authentication strategy

Hope this is not too broad but after a lot of googling I am not sure where to start. I am looking for a introductory/noob overview to help me get started on building an authentication implementation for a rails 3 application.
Basic technical requirements:
Rails 3 application is hosted on third party service (heroku)
Need to use specific external private SSO service to authenticate users.
No local user database or model in the rails application.
Authentication is token based meaning that there is a special cookie that needs to be read passing back token to SSO server (not rails based).
I have no control over the SSO server or infrastructure.
Trust of the SSO server is implicit and do not want to maintain local database of users, passwords, or sensitive information. User info only exists during session and the SSO server is authoritative.
Session token info is cookie based and lives for the duration of the browser session.
I am looking for basic example/tutorial/strategy/explanation of how the process would work in rails with the above setup. I would like the process to be seamless for user with workflow that basically looks like this:
Navigate to rails app -->
redirect unauthenticated users to SSO server -->
login and authenticate via remote SSO server -->
callback/redirect to rails app -->
capture user info passed back from SSO server and load protected resources in rails app
Strategy is completely custom using a private SSO resource and does not use a well published auth mechanism (in other words not Facebook, Google, Twitter, OAuth, etc).
Any help on terminology, coherent tutorials, examples would be appreciated.
Edit/Update:
To be more specific I am also looking for good documentation how to create an omniauth custom developer strategy. Some tutorial that goes through the kind of code required to talk to an arbitrary SSO server, read a token out of a cookie, and complete the authentication handshake and callback/redirect.
This isn't really an answer but I'm posting this because a comment just wouldn't do. I don't know of any comprehensive guides so here's what I'd suggest you do:
Learn how Omniauth works. There's a great Railscast about authentication using Twitter. It's really simple and it will get you in the flow of the thing.
Build your own Omniauth strategy. Go to the list of Omniauth Strategies and scroll to Developer Strategies. In that table, choose the strategy you can use to connect to your SSO server.
Ideally, you'd be able to use OAuth2 and there are a couple of guides that talk about implementing your own OAuth strategy:
Custom OAuth 1.0 strategy to connect to Rdio
Custom OAuth 2.0 strategy by Intridea (the creators of Omniauth)
Custom OAuth 2.0 strategy to connect to Force.com by Heroku
But since you can't, just give a quick look at those guides. Without any specifics it's kind of hard (for me) to give any more help, but hopefully someone else will fill in the details.

Is there an elegant way to integrate code performing authentication on other php site into Devise?

I am developing Rails application, in which I need to authorize users from other site written on PHP.
The APIs of PHP site written by its developer are custom i.e. they are not OmniAuth or similar.
I wonder, if there is elegant way to somehow integrate my code sending/receiving JSON responses to/from PHP site into Devise, so it could work like I am doing authentication of users in usual Devise way from my app.
Thanks.
Here is the link to official answer, I got from Devise maintainers: https://groups.google.com/d/msg/plataformatec-devise/lB4e0nYiM_U/RPDReqjO67QJ. Which means, the short answer is NO.

What's the best way to integrate Rails Restful Auth App Login into Wiki (MediaWiki?)

I have a ruby on rails app using restful authentication and I'm looking to add a Wiki to my site. MediaWiki looks like my best option since it's full featured and I can work with the LAMP stack. However, I'm not sold on MediaWiki if there's another (preferably open source) app that will integrate better.
I would like to know if anyone can suggest a way to integrate the login of my rails app with MediaWiki so users don't have to login twice or at the very least can have the same login credentials in both the rails and wiki app.
I've looked through the MediaWiki extensions but can't really determine which is the best solution. The current rails app is hosted on CentOS with enterprise ruby and phusion.
Perhaps not the cleanest solution but MediaWiki provides support for OpenID. Similialy, you can modify RESTful authentication to support OpenID here. This is discussed in the following post.
If both of your applications support OpenID then you've achieved your goals. If this is an internal solution, clearly this is not ideal.

Resources