File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,11 @@ def saml_settings
175
175
176
176
# Optional for most SAML IdPs
177
177
settings.authn_context = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
178
+ # or as an array
179
+ settings.authn_context = [
180
+ "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport",
181
+ "urn:oasis:names:tc:SAML:2.0:ac:classes:Password"
182
+ ]
178
183
179
184
# Optional bindings (defaults to Redirect for logout POST for acs)
180
185
settings.assertion_consumer_service_binding = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Original file line number Diff line number Diff line change @@ -136,8 +136,11 @@ def create_xml_document(settings)
136
136
}
137
137
138
138
if settings . authn_context != nil
139
- class_ref = requested_context . add_element "saml:AuthnContextClassRef"
140
- class_ref . text = settings . authn_context
139
+ authn_contexts = settings . authn_context . is_a? ( Array ) ? settings . authn_context : [ settings . authn_context ]
140
+ authn_contexts . each do |authn_context |
141
+ class_ref = requested_context . add_element "saml:AuthnContextClassRef"
142
+ class_ref . text = authn_context
143
+ end
141
144
end
142
145
# add saml:AuthnContextDeclRef element
143
146
if settings . authn_context_decl_ref != nil
Original file line number Diff line number Diff line change @@ -152,6 +152,13 @@ class RequestTest < Minitest::Test
152
152
assert_match /<saml:AuthnContextClassRef>secure\/ name\/ password\/ uri<\/ saml:AuthnContextClassRef>/ , auth_doc . to_s
153
153
end
154
154
155
+ it "create multiple saml:AuthnContextClassRef elements correctly" do
156
+ settings . authn_context = [ 'secure/name/password/uri' , 'secure/email/password/uri' ]
157
+ auth_doc = OneLogin ::RubySaml ::Authrequest . new . create_authentication_xml_doc ( settings )
158
+ assert_match /<saml:AuthnContextClassRef>secure\/ name\/ password\/ uri<\/ saml:AuthnContextClassRef>/ , auth_doc . to_s
159
+ assert_match /<saml:AuthnContextClassRef>secure\/ email\/ password\/ uri<\/ saml:AuthnContextClassRef>/ , auth_doc . to_s
160
+ end
161
+
155
162
it "create the saml:AuthnContextClassRef with comparison exact" do
156
163
settings . authn_context = 'secure/name/password/uri'
157
164
auth_doc = OneLogin ::RubySaml ::Authrequest . new . create_authentication_xml_doc ( settings )
You can’t perform that action at this time.
0 commit comments