Code Monkey home page Code Monkey logo

sso-devise-omniauth-client's Introduction

SSO with Devise and Omniauth Client

This is the client that uses ONLY omniauth to connect to a custom provider for single sign on between multiple applications.

Usage

git clone git://github.com/joshsoftware/sso-devise-omniauth-client.git
bundle install
rake db:create
rake db:migrate

Configure the Client

On the Provider, register this client application:

rails c
> @client = Client.new
> @client.app_id = 'some key'
> @client.app_secret = 'some secret'
> @client.save

Copy these same values in the Client config/initializers/omniauth.rb

APP_ID = 'some key' 
APP_SECRET = 'some secret'

# Update your custom Omniauth provider URL here
CUSTOM_PROVIDER_URL = 'http://localhost:3000'

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :josh_id, APP_ID, APP_SECRET
end

The custom Omniauth strategy

Since we want a single sign-on between our server and our client apps, we need to write a custom omniauth strategy. This is written in lib/josh_id.rb. Please implement your own and / or modify as required.

To test single sign-on

git clone git://github.com/joshsoftware/sso-devise-omniauth-client.git client1
git clone git://github.com/joshsoftware/sso-devise-omniauth-client.git client2

# configure the client1 key and secret in the provider as mentioned above

# In separater terminals start 2 clients
client1 $ rails s -p3001 
client2 $ rails s -p3002

Now, if you login via 1 client, and change the URL to the other, you will be automatically signed-in!

Contributions

Please feel free to enhance this demo. For any doubts, please send an email to [email protected]

I am eager to write some rspec for this setup. If you do, please send me a pull request!

License

This is released under the MIT license.

sso-devise-omniauth-client's People

Contributors

gautamrege avatar natebird avatar panupan avatar robzolkos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sso-devise-omniauth-client's Issues

Clarification on included lib/josh_id.rb strategy

Just to clarify, am I right in thinking that the included strategy lib/josh_id.rb is not used directly in this app? This app is just a consumer. The provider app is the one that needs to implement the strategy, right?

So including it here is just for what, convenience?

Sign Out Problem

Thanks Josh for all the hard work. You saved me a bunch of time trying to figure this all out on my own. There is one quirk that remains to be solved. When you sign out of one child app you remained signed in on the other child apps. I'm guessing this is because even though you destroy the session of the child app and the auth app, the remaining child apps still have their session. I'm not sure how to solve this. Any ideas?

License?

We'd like to use this gem and its provider sister in a project under development, but we need to make sure it uses a compatible license (in our case, Simplified BSD, MIT, or Apache 2.0). There is no license specified for this project; does it have one? If not, can it be released under one of these three?

Unable to access the client

When I go to "http://localhost:3001/" it redirects to "http://localhost:3001/auth/joshid/callback?code=2eecb781f11d54d03f6f687b3e9ac35f&response_type=code&state=ab1321c56448a697cd54e2b526afe1c06d6c7ee8b5c28971" and got following error

OAuth2::Error

You need to sign in or sign up before continuing.:
{"error":"You need to sign in or sign up before continuing."}
Rails.root: /home/mathan/work/projects/p/sso-devise-omniauth-client

Application Trace | Framework Trace | Full Trace
lib/josh_id.rb:30:in raw_info' lib/josh_id.rb:14:inblock in class:JoshId'
Request

Parameters:

{"code"=>"2eecb781f11d54d03f6f687b3e9ac35f",
"response_type"=>"code",
"state"=>"ab1321c56448a697cd54e2b526afe1c06d6c7ee8b5c28971"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.