File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -136,16 +136,19 @@ def create_xml_document(settings)
136
136
}
137
137
138
138
if settings . authn_context != nil
139
- authn_contexts = settings . authn_context . is_a? ( Array ) ? settings . authn_context : [ settings . authn_context ]
140
- authn_contexts . each do |authn_context |
139
+ authn_contexts_class_ref = settings . authn_context . is_a? ( Array ) ? settings . authn_context : [ settings . authn_context ]
140
+ authn_contexts_class_ref . each do |authn_context_class_ref |
141
141
class_ref = requested_context . add_element "saml:AuthnContextClassRef"
142
- class_ref . text = authn_context
142
+ class_ref . text = authn_context_class_ref
143
143
end
144
144
end
145
- # add saml:AuthnContextDeclRef element
145
+
146
146
if settings . authn_context_decl_ref != nil
147
- class_ref = requested_context . add_element "saml:AuthnContextDeclRef"
148
- class_ref . text = settings . authn_context_decl_ref
147
+ authn_contexts_decl_refs = settings . authn_context_decl_ref . is_a? ( Array ) ? settings . authn_context_decl_ref : [ settings . authn_context_decl_ref ]
148
+ authn_contexts_decl_refs . each do |authn_context_decl_ref |
149
+ decl_ref = requested_context . add_element "saml:AuthnContextDeclRef"
150
+ decl_ref . text = authn_context_decl_ref
151
+ end
149
152
end
150
153
end
151
154
Original file line number Diff line number Diff line change @@ -285,5 +285,12 @@ class RequestTest < Minitest::Test
285
285
auth_doc = OneLogin ::RubySaml ::Authrequest . new . create_authentication_xml_doc ( settings )
286
286
assert auth_doc . to_s =~ /<saml:AuthnContextDeclRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport<\/ saml:AuthnContextDeclRef>/
287
287
end
288
+
289
+ it "create multiple saml:AuthnContextDeclRef elements correctly " do
290
+ settings . authn_context_decl_ref = [ 'name/password/uri' , 'example/decl/ref' ]
291
+ auth_doc = OneLogin ::RubySaml ::Authrequest . new . create_authentication_xml_doc ( settings )
292
+ assert auth_doc . to_s =~ /<saml:AuthnContextDeclRef>name\/ password\/ uri<\/ saml:AuthnContextDeclRef>/
293
+ assert auth_doc . to_s =~ /<saml:AuthnContextDeclRef>example\/ decl\/ ref<\/ saml:AuthnContextDeclRef>/
294
+ end
288
295
end
289
296
end
You can’t perform that action at this time.
0 commit comments