File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,8 +16,10 @@ module RubySaml
1616 #
1717 class IdpMetadataParser
1818
19- METADATA = "urn:oasis:names:tc:SAML:2.0:metadata"
20- DSIG = "http://www.w3.org/2000/09/xmldsig#"
19+ METADATA = "urn:oasis:names:tc:SAML:2.0:metadata"
20+ DSIG = "http://www.w3.org/2000/09/xmldsig#"
21+ NAME_FORMAT = "urn:oasis:names:tc:SAML:2.0:attrname-format:*"
22+ SAML_ASSERTION = "urn:oasis:names:tc:SAML:2.0:assertion"
2123
2224 attr_reader :document
2325 attr_reader :response
@@ -46,6 +48,7 @@ def parse(idp_metadata)
4648 settings . idp_slo_target_url = single_logout_service_url
4749 settings . idp_cert = certificate_base64
4850 settings . idp_cert_fingerprint = fingerprint
51+ settings . idp_attribute_names = attribute_names
4952 end
5053 end
5154
@@ -166,6 +169,17 @@ def fingerprint
166169 end
167170 end
168171 end
172+
173+ # @return [Array] the names of all SAML attributes if any exist
174+ #
175+ def attribute_names
176+ nodes = REXML ::XPath . match (
177+ document ,
178+ "/md:EntityDescriptor/md:IDPSSODescriptor/saml:Attribute/@Name" ,
179+ { "md" => METADATA , "NameFormat" => NAME_FORMAT , "saml" => SAML_ASSERTION }
180+ )
181+ nodes . map ( &:value )
182+ end
169183 end
170184 end
171185end
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ def initialize(overrides = {})
2828 attr_accessor :idp_cert
2929 attr_accessor :idp_cert_fingerprint
3030 attr_accessor :idp_cert_fingerprint_algorithm
31+ attr_accessor :idp_attribute_names
3132 # SP Data
3233 attr_accessor :issuer
3334 attr_accessor :assertion_consumer_service_url
You can’t perform that action at this time.
0 commit comments