Skip to content

Commit 76ed3d6

Browse files
author
Jiongye Li
committed
feat: added the response object to the extra['response_object'], so we can use the raw response object if we want to
1 parent 146e469 commit 76ed3d6

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ end
6868

6969
For IdP-initiated SSO, users should directly access the IdP SSO target URL. Set the `href` of your application's login link to the value of `idp_sso_target_url`. For SP-initiated SSO, link to `/auth/saml`.
7070

71+
A `OneLogin::RubySaml::Response` object is added to the `env['omniauth.auth']` extra attribute, so we can use it in the controller via `env['omniauth.auth'].extra.response_object`
72+
7173
## Metadata
7274

7375
The service provider metadata used to ease configuration of the SAML SP in the IdP can be retrieved from `http://example.com/auth/saml/metadata`. Send this URL to the administrator of the IdP.

lib/omniauth/strategies/saml.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def callback_phase
7676

7777
@name_id = response.name_id
7878
@attributes = response.attributes
79+
@response_object = response
7980

8081
if @name_id.nil? || @name_id.empty?
8182
raise OmniAuth::Strategies::SAML::ValidationError.new("SAML response missing 'name_id'")
@@ -135,7 +136,7 @@ def other_phase
135136
Hash[found_attributes]
136137
end
137138

138-
extra { { :raw_info => @attributes } }
139+
extra { { :raw_info => @attributes, :response_object => @response_object } }
139140

140141
def find_attribute_by(keys)
141142
keys.each do |key|

spec/omniauth/strategies/saml_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ def post_xml(xml=:example_response)
114114
'fingerprint' => saml_options[:idp_cert_fingerprint]
115115
}
116116
end
117+
118+
it "should set the response_object to the response object from ruby_saml response" do
119+
auth_hash['extra']['response_object'].should be_kind_of(OneLogin::RubySaml::Response)
120+
end
117121
end
118122

119123
context "when fingerprint is empty and there's a fingerprint validator" do

0 commit comments

Comments
 (0)