Skip to content

Commit b538bdf

Browse files
committed
Add request_id, response_id and assertion_id
1 parent 60b0204 commit b538bdf

6 files changed

Lines changed: 32 additions & 1 deletion

File tree

lib/onelogin/ruby-saml/authrequest.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def initialize
2424
@uuid = OneLogin::RubySaml::Utils.uuid
2525
end
2626

27+
def request_id
28+
@uuid
29+
end
30+
2731
# Creates the AuthNRequest string.
2832
# @param settings [OneLogin::RubySaml::Settings|nil] Toolkit settings
2933
# @param params [Hash] Some extra parameters to be added in the GET for example the RelayState

lib/onelogin/ruby-saml/logoutrequest.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def initialize
2121
@uuid = OneLogin::RubySaml::Utils.uuid
2222
end
2323

24+
def request_id
25+
@uuid
26+
end
27+
2428
# Creates the Logout Request string.
2529
# @param settings [OneLogin::RubySaml::Settings|nil] Toolkit settings
2630
# @param params [Hash] Some extra parameters to be added in the GET for example the RelayState

lib/onelogin/ruby-saml/logoutresponse.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def initialize(response, settings = nil, options = {})
4747
@document = XMLSecurity::SignedDocument.new(@response)
4848
end
4949

50+
def response_id
51+
id(document)
52+
end
53+
5054
# Checks if the Status has the "Success" code
5155
# @return [Boolean] True if the StatusCode is Sucess
5256
# @raise [ValidationError] if soft == false and validation fails

lib/onelogin/ruby-saml/response.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,17 @@ def assertion_encrypted?
354354
).nil?
355355
end
356356

357+
def response_id
358+
id(document)
359+
end
360+
361+
def assertion_id
362+
@assertion_id ||= begin
363+
node = xpath_first_from_signed_assertion("")
364+
node.nil? ? nil : node.attributes['ID']
365+
end
366+
end
367+
357368
private
358369

359370
# Validates the SAML Response (calls several validation methods)
@@ -448,7 +459,7 @@ def validate_response_state
448459
# @return [Boolean] True if the SAML Response contains an ID, otherwise returns False
449460
#
450461
def validate_id
451-
unless id(document)
462+
unless response_id
452463
return append_error("Missing ID attribute on SAML Response")
453464
end
454465

lib/onelogin/ruby-saml/slo_logoutrequest.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def initialize(request, options = {})
4747
@document = REXML::Document.new(@request)
4848
end
4949

50+
def request_id
51+
id(document)
52+
end
53+
5054
# Validates the Logout Request with the default values (soft = true)
5155
# @param collect_errors [Boolean] Stop validation when first error appears or keep validating.
5256
# @return [Boolean] TRUE if the Logout Request is valid

lib/onelogin/ruby-saml/slo_logoutresponse.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def initialize
2222
@uuid = OneLogin::RubySaml::Utils.uuid
2323
end
2424

25+
def response_id
26+
@uuid
27+
end
28+
2529
# Creates the Logout Response string.
2630
# @param settings [OneLogin::RubySaml::Settings|nil] Toolkit settings
2731
# @param request_id [String] The ID of the LogoutRequest sent by this SP to the IdP. That ID will be placed as the InResponseTo in the logout response

0 commit comments

Comments
 (0)