Skip to content

Commit fb44202

Browse files
Zogoozogoomjobin-mdsol
authored
[fix] Accept reference id for SAML response (#226)
* Squash commits for saml_idp gem * [feat] Allow SP config force signature validation (#16) * Allow SP config force signature validation * Allow SP config force signature validation Tested with Slack with Authn request signature option --------- Co-authored-by: zogoo <[email protected]> * [feat] Don’t ignore certificates without usage (#17) I have tested with live SAML SP apps and it works fine * Unspecified certifciate from SP metadata --------- Co-authored-by: zogoo <[email protected]> * Try with proper way to update helper method (#19) * Set minimum test coverage (#207) * Set minimum test coverage to a very high value for testing * Update minimum coverage to actual current value * Try with proper way to update helper method * Correctly decode and mock with correct REXML class * Drop the min coverage --------- Co-authored-by: Mathieu Jobin <[email protected]> Co-authored-by: zogoo <[email protected]> * [feat] Collect request validation errors (#18) * wip add error collector * Fix type and rewrite request with proper validation test cases * Lead error render decision to gem user * Validate the certificate's existence before verifying the signature. --------- Co-authored-by: zogoo <[email protected]> * Support lowercase percent-encoded sequences for URL encoding (#20) Co-authored-by: zogoo <[email protected]> * Pass ref id as Session Index * Official Rails 8 is not released yet to RubyGem until that let's stick official older version * [fix] Gem CI updates for latest versions (#22) * Remove duplications * Pre-conditions need to be defined in before section * Le's not test logger in here --------- Co-authored-by: zogoo <[email protected]> * [fix] Allow IdP set reference ID for SAML response (#21) * Pass ref id as Session Index * Official Rails 8 is not released yet to RubyGem until that let's stick official older version --------- Co-authored-by: zogoo <[email protected]> * Fixes for ORIGIN gem --------- Co-authored-by: zogoo <[email protected]> Co-authored-by: Mathieu Jobin <[email protected]>
1 parent 6f832af commit fb44202

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/saml_idp/saml_response.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def response_builder
9898

9999
def assertion_builder
100100
@assertion_builder ||=
101-
AssertionBuilder.new SecureRandom.uuid,
101+
AssertionBuilder.new(reference_id || SecureRandom.uuid,
102102
issuer_uri,
103103
principal,
104104
audience_uri,
@@ -110,7 +110,7 @@ def assertion_builder
110110
encryption_opts,
111111
session_expiry,
112112
name_id_formats_opts,
113-
asserted_attributes_opts
113+
asserted_attributes_opts)
114114
end
115115
private :assertion_builder
116116
end

spec/lib/saml_idp/saml_response_spec.rb

+19
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,25 @@ module SamlIdp
192192
expect(saml_resp.is_valid?).to eq(true)
193193
end
194194

195+
it "will pass reference_id as SessionIndex" do
196+
expect { subject.build }.not_to raise_error
197+
signed_encoded_xml = subject.build
198+
resp_settings = saml_settings(saml_acs_url)
199+
resp_settings.private_key = Default::SECRET_KEY
200+
resp_settings.issuer = audience_uri
201+
saml_resp = OneLogin::RubySaml::Response.new(signed_encoded_xml, settings: resp_settings)
202+
203+
expect(
204+
Nokogiri::XML(saml_resp.response).at_xpath(
205+
"//saml:AuthnStatement/@SessionIndex",
206+
{
207+
"samlp" => "urn:oasis:names:tc:SAML:2.0:protocol",
208+
"saml" => "urn:oasis:names:tc:SAML:2.0:assertion"
209+
}
210+
).value
211+
).to eq("_#{reference_id}")
212+
end
213+
195214
it "sets session expiration" do
196215
saml_resp = OneLogin::RubySaml::Response.new(subject.build)
197216
expect(saml_resp.session_expires_at).to eq Time.local(1990, "jan", 2).iso8601

0 commit comments

Comments
 (0)