Skip to content

Commit f91308d

Browse files
committed
Expose NameID Format on SloLogoutrequest
Equivalent to `name_id_format` (`nameid_format`) on `Response` class.
1 parent b3ac5bd commit f91308d

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/onelogin/ruby-saml/slo_logoutrequest.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ def name_id
6666

6767
alias_method :nameid, :name_id
6868

69+
# @return [String] Gets the NameID Format of the Logout Request.
70+
#
71+
def name_id_format
72+
@name_id_node ||= REXML::XPath.first(document, "/p:LogoutRequest/a:NameID", { "p" => PROTOCOL, "a" => ASSERTION })
73+
@name_id_format ||=
74+
if @name_id_node && @name_id_node.attribute("Format")
75+
@name_id_node.attribute("Format").value
76+
end
77+
end
78+
79+
alias_method :nameid_format, :name_id_format
80+
6981
# @return [String|nil] Gets the ID attribute from the Logout Request. if exists.
7082
#
7183
def id
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<samlp:LogoutRequest Version='2.0' ID='_c0348950-935b-0131-1060-782bcb56fcaa' xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol' IssueInstant='2014-03-21T19:20:13'>
22
<saml:Issuer xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>https://app.onelogin.com/saml/metadata/SOMEACCOUNT</saml:Issuer>
3-
<saml:NameID xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>someone@example.org</saml:NameID>
3+
<saml:NameID xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion' Format='urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'>someone@example.org</saml:NameID>
44
</samlp:LogoutRequest>

test/slo_logoutrequest_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ class RubySamlTest < Minitest::Test
9191
end
9292
end
9393

94+
describe "#nameid_format" do
95+
it "extract the format attribute of the name id element" do
96+
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", logout_request.nameid_format
97+
end
98+
end
99+
94100
describe "#issuer" do
95101
it "return the issuer inside the logout request" do
96102
assert_equal "https://app.onelogin.com/saml/metadata/SOMEACCOUNT", logout_request.issuer

0 commit comments

Comments
 (0)