Browse files

#8939. single sign out

  • Loading branch information...
1 parent e0c6258 commit 362e57ec0d78ed45fe14abd54ab2221375ed4183 @lda lda committed Dec 13, 2011
Showing with 24 additions and 4 deletions.
  1. +19 −0 app/controllers/sso_client/sessions_controller.rb
  2. +4 −3 config/routes.rb
  3. +1 −1 spec/dummy/app/views/home/show.html.erb
View
19 app/controllers/sso_client/sessions_controller.rb
@@ -0,0 +1,19 @@
+class SsoClient::SessionsController < Devise::SessionsController
+ def new
+ redirect_to '/sso/auth/identity'
+ end
+ def destroy
+ sign_out :user
+ redirect_to "#{Settings['sso_provider.host']}/users/sign_out?redirect_uri=#{CGI.escape(redirect_uri)}"
+ end
+
+ protected
+
+ def redirect_uri
+ URI.parse(request.url).tap do | uri |
+ uri.path = main_app.root_path
+ uri.query = nil
+ end.to_s
+ end
+
+end
View
7 config/routes.rb
@@ -3,9 +3,10 @@
:path => 'sso',
:skip => [:registrations, :passwords, :confirmations],
:controllers => {:omniauth_callbacks => "sso_client/omniauth_callbacks"} do
- get 'sign_in' => redirect('/sso/auth/identity'), :as => :new_user_session
- get "sign_out", :to => "devise/sessions#destroy"
+ get '/sso/sign_in' => redirect('/sso/auth/identity'), :as => :new_user_session
+ get "/sso/sign_out", :to => "sso_client/sessions#destroy"
end
- get '/sso/auth/identity', :as => :single_sign_on
+ get '/sso/auth/identity', :as => :sign_on
+ get "/sso/sign_out", :as => :sign_out
end
View
2 spec/dummy/app/views/home/show.html.erb
@@ -3,7 +3,7 @@
<% flash[:notice] = nil %>
<% end %>
<% if not current_user %>
- <%= link_to 'login', single_sign_on_path %>
+ <%= link_to 'login', sign_on_path %>
<% else %>
<h1>Hello <%= current_user.name %>!</h1>
<%= link_to 'logout', sign_out_path %>

0 comments on commit 362e57e

Please sign in to comment.