File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ def parse(idp_metadata)
2525 @document = REXML ::Document . new ( idp_metadata )
2626
2727 OneLogin ::RubySaml ::Settings . new . tap do |settings |
28-
28+ settings . idp_entity_id = idp_entity_id
29+ settings . name_identifier_format = idp_name_id_format
2930 settings . idp_sso_target_url = single_signon_service_url
3031 settings . idp_slo_target_url = single_logout_service_url
3132 settings . idp_cert_fingerprint = fingerprint
@@ -57,6 +58,16 @@ def get_idp_metadata(url, validate_cert)
5758 meta_text
5859 end
5960
61+ def idp_entity_id
62+ node = REXML ::XPath . first ( document , "/md:EntityDescriptor/@entityID" , { "md" => METADATA } )
63+ node . value if node
64+ end
65+
66+ def idp_name_id_format
67+ node = REXML ::XPath . first ( document , "/md:EntityDescriptor/md:IDPSSODescriptor/md:NameIDFormat" , { "md" => METADATA } )
68+ node . text if node
69+ end
70+
6071 def single_signon_service_url
6172 node = REXML ::XPath . first ( document , "/md:EntityDescriptor/md:IDPSSODescriptor/md:SingleSignOnService/@Location" , { "md" => METADATA } )
6273 node . value if node
Original file line number Diff line number Diff line change @@ -14,9 +14,11 @@ class MockResponse
1414
1515 settings = idp_metadata_parser . parse ( idp_metadata )
1616
17+ assert_equal "https://example.hello.com/access/saml/idp.xml" , settings . idp_entity_id
1718 assert_equal "https://example.hello.com/access/saml/login" , settings . idp_sso_target_url
1819 assert_equal "F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72" , settings . idp_cert_fingerprint
1920 assert_equal "https://example.hello.com/access/saml/logout" , settings . idp_slo_target_url
21+ assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" , settings . name_identifier_format
2022 end
2123 end
2224
@@ -37,9 +39,11 @@ class MockResponse
3739 idp_metadata_parser = OneLogin ::RubySaml ::IdpMetadataParser . new
3840 settings = idp_metadata_parser . parse_remote ( @url )
3941
42+ assert_equal "https://example.hello.com/access/saml/idp.xml" , settings . idp_entity_id
4043 assert_equal "https://example.hello.com/access/saml/login" , settings . idp_sso_target_url
4144 assert_equal "F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72" , settings . idp_cert_fingerprint
4245 assert_equal "https://example.hello.com/access/saml/logout" , settings . idp_slo_target_url
46+ assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" , settings . name_identifier_format
4347 assert_equal OpenSSL ::SSL ::VERIFY_PEER , @http . verify_mode
4448 end
4549
You can’t perform that action at this time.
0 commit comments