-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #255 from codez/multiple-user-sessions
Store IDP session index in session to allow multiple sessions per user
- Loading branch information
Showing
8 changed files
with
42 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ def destroy | |
|
||
describe Devise::SamlSessionsController, type: :controller do | ||
include RubySamlSupport | ||
include Devise::Test::ControllerHelpers | ||
|
||
let(:idp_providers_adapter) { spy('Stub IDPSettings Adaptor') } | ||
|
||
|
@@ -256,7 +257,8 @@ def all_signed_out? | |
end | ||
|
||
it 'includes a LogoutRequest with the name identifier and session index', :aggregate_failures do | ||
controller.current_user = Struct.new(:email, :session_index).new('[email protected]', 'sessionindex') | ||
controller.current_user = Struct.new(:email).new('[email protected]') | ||
session[Devise.saml_session_index_key] = 'sessionindex' | ||
|
||
actual_settings = nil | ||
expect_any_instance_of(OneLogin::RubySaml::Logoutrequest).to receive(:create) do |_, settings| | ||
|
@@ -322,9 +324,10 @@ def self.entity_id(params) | |
end | ||
|
||
it 'returns invalid request if SAMLRequest or SAMLResponse is not passed' do | ||
expect(User).not_to receive(:reset_session_key_for) | ||
session[Devise.saml_session_index_key] = 'sessionindex' | ||
post :idp_sign_out | ||
expect(response.status).to eq 500 | ||
expect(session[Devise.saml_session_index_key]).to eq('sessionindex') | ||
end | ||
|
||
context 'when receiving a logout response from the IdP after redirecting an SP logout request' do | ||
|
@@ -367,13 +370,13 @@ def self.entity_id(params) | |
let(:name_id) { '12312312' } | ||
before do | ||
allow(OneLogin::RubySaml::SloLogoutrequest).to receive(:new).and_return(saml_request) | ||
allow(User).to receive(:reset_session_key_for) | ||
session[Devise.saml_session_index_key] = 'sessionindex' | ||
end | ||
|
||
it 'direct the resource to reset the session key' do | ||
do_post | ||
expect(response).to redirect_to response_url | ||
expect(User).to have_received(:reset_session_key_for).with(name_id) | ||
expect(session[Devise.saml_session_index_key]).to be_nil | ||
end | ||
|
||
context 'with a specified idp' do | ||
|
@@ -387,6 +390,7 @@ def self.entity_id(params) | |
expect(response.status).to eq 302 | ||
expect(idp_providers_adapter).to have_received(:settings).with(idp_entity_id, request) | ||
expect(response).to redirect_to 'http://localhost/logout_response' | ||
expect(session[Devise.saml_session_index_key]).to be_nil | ||
end | ||
end | ||
|
||
|
@@ -407,7 +411,6 @@ def self.entity_id(params) | |
end | ||
|
||
it 'returns invalid request' do | ||
expect(User).not_to receive(:reset_session_key_for).with(name_id) | ||
do_post | ||
expect(response.status).to eq 500 | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,10 +103,7 @@ class SamlIdpController < StubSamlIdp::IdpController | |
def sp_sign_out | ||
idp_slo_authenticate(params[:name_id]) | ||
saml_slo_request = encode_SAML_SLO_Request("[email protected]") | ||
uri = URI.parse("http://localhost:8020/users/saml/idp_sign_out") | ||
require 'net/http' | ||
Net::HTTP.post_form(uri, {"SAMLRequest" => saml_slo_request}) | ||
head :no_content | ||
redirect_to "http://localhost:8020/users/saml/idp_sign_out?SAMLRequest=#{URI.encode_www_form_component(saml_slo_request)}" | ||
end | ||
|
||
def idp_slo_authenticate(email) | ||
|