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 @@ -27,7 +27,8 @@ def parse(idp_metadata)
2727 @document = REXML ::Document . new ( idp_metadata )
2828
2929 OneLogin ::RubySaml ::Settings . new . tap do |settings |
30-
30+ settings . idp_entity_id = idp_entity_id
31+ settings . name_identifier_format = idp_name_id_format
3132 settings . idp_sso_target_url = single_signon_service_url
3233 settings . idp_slo_target_url = single_logout_service_url
3334 settings . idp_cert_fingerprint = fingerprint
@@ -65,6 +66,16 @@ def get_idp_metadata(url, validate_cert)
6566 meta_text
6667 end
6768
69+ def idp_entity_id
70+ node = REXML ::XPath . first ( document , "/md:EntityDescriptor/@entityID" , { "md" => METADATA } )
71+ node . value if node
72+ end
73+
74+ def idp_name_id_format
75+ node = REXML ::XPath . first ( document , "/md:EntityDescriptor/md:IDPSSODescriptor/md:NameIDFormat" , { "md" => METADATA } )
76+ node . text if node
77+ end
78+
6879 def single_signon_service_url
6980 node = REXML ::XPath . first ( document , "/md:EntityDescriptor/md:IDPSSODescriptor/md:SingleSignOnService/@Location" , { "md" => METADATA } )
7081 node . value if node
Original file line number Diff line number Diff line change @@ -12,9 +12,11 @@ class MockResponse
1212
1313 settings = idp_metadata_parser . parse ( idp_metadata )
1414
15+ assert_equal "https://example.hello.com/access/saml/idp.xml" , settings . idp_entity_id
1516 assert_equal "https://example.hello.com/access/saml/login" , settings . idp_sso_target_url
1617 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
1718 assert_equal "https://example.hello.com/access/saml/logout" , settings . idp_slo_target_url
19+ assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" , settings . name_identifier_format
1820 end
1921 end
2022
@@ -35,9 +37,11 @@ class MockResponse
3537 idp_metadata_parser = OneLogin ::RubySaml ::IdpMetadataParser . new
3638 settings = idp_metadata_parser . parse_remote ( @url )
3739
40+ assert_equal "https://example.hello.com/access/saml/idp.xml" , settings . idp_entity_id
3841 assert_equal "https://example.hello.com/access/saml/login" , settings . idp_sso_target_url
3942 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
4043 assert_equal "https://example.hello.com/access/saml/logout" , settings . idp_slo_target_url
44+ assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" , settings . name_identifier_format
4145 assert_equal OpenSSL ::SSL ::VERIFY_PEER , @http . verify_mode
4246 end
4347
You can’t perform that action at this time.
0 commit comments