Skip to content

Commit ae5745a

Browse files
committed
Alias/deprecate more params:
- certificate --> sp_cert - private_key --> sp_private_key - assertion_consumer_service_url --> sp_assertion_consumer_service_url - assertion_consumer_service_binding --> sp_assertion_consumer_service_binding - single_logout_service_url --> sp_slo_service_url - single_logout_service_binding --> sp_slo_service_binding
1 parent 3229214 commit ae5745a

20 files changed

+327
-197
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ If you don't know what expect, always use the former (set the settings on initia
191191
def saml_settings
192192
settings = RubySaml::Settings.new
193193
194-
settings.assertion_consumer_service_url = "http://#{request.host}/saml/consume"
194+
settings.sp_assertion_consumer_service_url = "http://#{request.host}/saml/consume"
195195
settings.sp_entity_id = "http://#{request.host}/saml/metadata"
196196
settings.idp_entity_id = "https://app.onelogin.com/saml/metadata/#{OneLoginAppId}"
197197
settings.idp_sso_service_url = "https://app.onelogin.com/trust/saml2/http-post/sso/#{OneLoginAppId}"
@@ -211,8 +211,8 @@ def saml_settings
211211
]
212212
213213
# Optional bindings (defaults to Redirect for logout POST for ACS)
214-
settings.single_logout_service_binding = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" # or :post, :redirect
215-
settings.assertion_consumer_service_binding = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" # or :post, :redirect
214+
settings.sp_slo_service_binding = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" # or :post, :redirect
215+
settings.sp_assertion_consumer_service_binding = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" # or :post, :redirect
216216
217217
settings
218218
end
@@ -263,11 +263,11 @@ class SamlController < ApplicationController
263263
def saml_settings
264264
settings = RubySaml::Settings.new
265265
266-
settings.assertion_consumer_service_url = "http://#{request.host}/saml/consume"
267-
settings.sp_entity_id = "http://#{request.host}/saml/metadata"
268-
settings.idp_sso_service_url = "https://app.onelogin.com/saml/signon/#{OneLoginAppId}"
269-
settings.idp_cert_fingerprint = OneLoginAppCertFingerPrint
270-
settings.name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
266+
settings.sp_assertion_consumer_service_url = "http://#{request.host}/saml/consume"
267+
settings.sp_entity_id = "http://#{request.host}/saml/metadata"
268+
settings.idp_sso_service_url = "https://app.onelogin.com/saml/signon/#{OneLoginAppId}"
269+
settings.idp_cert_fingerprint = OneLoginAppCertFingerPrint
270+
settings.name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
271271
272272
# Optional for most SAML IdPs
273273
settings.authn_context = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
@@ -338,9 +338,9 @@ def saml_settings
338338
# Returns RubySaml::Settings pre-populated with IdP metadata
339339
settings = idp_metadata_parser.parse_remote("https://example.com/auth/saml2/idp/metadata")
340340
341-
settings.assertion_consumer_service_url = "http://#{request.host}/saml/consume"
342-
settings.sp_entity_id = "http://#{request.host}/saml/metadata"
343-
settings.name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
341+
settings.sp_assertion_consumer_service_url = "http://#{request.host}/saml/consume"
342+
settings.sp_entity_id = "http://#{request.host}/saml/metadata"
343+
settings.name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
344344
# Optional for most SAML IdPs
345345
settings.authn_context = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
346346
@@ -622,8 +622,8 @@ Ruby SAML supports the following functionality:
622622
In order to use functions 1-3 above, you must first define your SP public certificate and private key:
623623
624624
```ruby
625-
settings.certificate = "CERTIFICATE TEXT WITH BEGIN/END HEADER AND FOOTER"
626-
settings.private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
625+
settings.sp_cert = "CERTIFICATE TEXT WITH BEGIN/END HEADER AND FOOTER"
626+
settings.sp_private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
627627
```
628628
629629
Note that the same certificate (and its associated private key) are used to perform
@@ -642,8 +642,8 @@ You may also globally set the SP signature and digest method, to be used in SP s
642642
You may add a `<ds:Signature>` digital signature element to your SP Metadata XML using the following setting:
643643
644644
```ruby
645-
settings.certificate = "CERTIFICATE TEXT WITH BEGIN/END HEADER AND FOOTER"
646-
settings.private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
645+
settings.sp_cert = "CERTIFICATE TEXT WITH BEGIN/END HEADER AND FOOTER"
646+
settings.sp_private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
647647
648648
settings.security[:metadata_signed] = true # Enable signature on Metadata
649649
```
@@ -658,8 +658,8 @@ To enable, please first set your certificate and private key. This will add `<md
658658
to your SP Metadata XML, to be read by the IdP.
659659
660660
```ruby
661-
settings.certificate = "CERTIFICATE TEXT WITH BEGIN/END HEADER AND FOOTER"
662-
settings.private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
661+
settings.sp_cert = "CERTIFICATE TEXT WITH BEGIN/END HEADER AND FOOTER"
662+
settings.sp_private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
663663
```
664664
665665
Next, you may specify the specific SP SAML messages you would like to sign:
@@ -684,8 +684,8 @@ You may enable EncryptedAssertion as follows. This will add `<md:KeyDescriptor u
684684
SP Metadata XML, to be read by the IdP.
685685
686686
```ruby
687-
settings.certificate = "CERTIFICATE TEXT WITH BEGIN/END HEADER AND FOOTER"
688-
settings.private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
687+
settings.sp_cert = "CERTIFICATE TEXT WITH BEGIN/END HEADER AND FOOTER"
688+
settings.sp_private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
689689
690690
settings.security[:want_assertions_encrypted] = true # Invalidate SAML messages without an EncryptedAssertion
691691
```

UPGRADING.md

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ settings.security[:digest_method] = RubySaml::XML::Document::SHA1
5050
settings.security[:signature_method] = RubySaml::XML::Document::RSA_SHA1
5151
```
5252

53-
### Removal of embed_sign Setting
53+
### Removal of security[:embed_sign] setting
5454

5555
The deprecated `settings.security[:embed_sign]` parameter has been removed. If you were using it, please instead switch
5656
to using both the `settings.idp_sso_service_binding` and `settings.idp_slo_service_binding` parameters as show below.
@@ -68,10 +68,10 @@ settings.idp_slo_service_binding = :redirect
6868

6969
For clarity, the default value of both parameters is `:redirect` if they are not set.
7070

71-
### Deprecation of Compression Settings
71+
### Deprecation of compression settings
7272

7373
The `settings.compress_request` and `settings.compress_response` parameters have been deprecated
74-
and are no longer functional. They will be removed in RubySaml 2.1.0. Please remove `compress_request`
74+
and are no longer functional. **They will be removed in RubySaml 2.1.0.** Please remove `compress_request`
7575
and `compress_response` everywhere within your project code.
7676

7777
The SAML SP request/response message compression behavior is now controlled automatically by the
@@ -80,17 +80,47 @@ The SAML SP request/response message compression behavior is now controlled auto
8080
"compression" is used to make redirect URLs which contain SAML messages be shorter. For POST messages,
8181
compression may be achieved by enabling `Content-Encoding: gzip` on your webserver.
8282

83-
## Settings deprecations
83+
### Deprecation of certificate_new setting
8484

85-
The following parameters in `RubySaml::Settings` are deprecated and will be removed in RubySaml 2.1.0:
85+
The `settings.certificate_new` parameter has been deprecated in favor of `settings.sp_cert_multi`,
86+
and **will be removed in RubySaml 2.1.0.** If you are using `certificate_new` you
87+
will need to replace **all** of the `certificate`, `certificate_new`, and `private_key` params
88+
with `sp_cert_multi` as shown below:
8689

87-
- `#issuer` is deprecated and replaced 1:1 by `#sp_entity_id`
88-
- `#idp_sso_target_url` is deprecated and replaced 1:1 by `#idp_sso_service_url`
89-
- `#idp_slo_target_url` is deprecated and replaced 1:1 by `#idp_slo_service_url`
90-
- `#assertion_consumer_logout_service_url` is deprecated and replaced 1:1 by `#single_logout_service_url`
91-
- `#assertion_consumer_logout_service_binding` is deprecated and replaced 1:1 by `#single_logout_service_binding`
92-
- `#certificate_new` is deprecated and replaced by `#sp_cert_multi`. Refer to documentation as `#sp_cert_multi`
93-
has a different value type than `#certificate_new`.
90+
```ruby
91+
settings.sp_cert_multi = {
92+
signing: [
93+
{ certificate: (certificate), private_key: (private_key) },
94+
{ certificate: (certificate_new), private_key: (private_key) }
95+
],
96+
encryption: [
97+
{ certificate: (certificate), private_key: (private_key) },
98+
{ certificate: (certificate_new), private_key: (private_key) }
99+
],
100+
}
101+
```
102+
103+
## Settings parameter deprecations
104+
105+
The following parameters in `RubySaml::Settings` are deprecated and replaced 1-for-1 with new parameters.
106+
The new names clarify which parameters belong to the SP and which to the IdP.
107+
Until RubySaml 3.0.0, using the old method will raise a deprecation warning but otherwise function as an alias
108+
to the new parameter. Beginning in **RubySaml 3.0.0**, using the old method will raise a `NotImplemented` error.
109+
Aside from the name change, there are no changes to the usage or functionality of these parameters.
110+
111+
| Old Parameter | New Parameter |
112+
|---------------------------------------------|-----------------------------------------|
113+
| `issuer` | `sp_entity_id` |
114+
| `certificate` | `sp_cert` |
115+
| `private_key` | `sp_private_key` |
116+
| `assertion_consumer_service_url` | `sp_assertion_consumer_service_url` |
117+
| `assertion_consumer_service_binding` | `sp_assertion_consumer_service_binding` |
118+
| `assertion_consumer_logout_service_url` | `sp_slo_service_url` |
119+
| `single_logout_service_url` | `sp_slo_service_url` |
120+
| `assertion_consumer_logout_service_binding` | `sp_slo_service_binding` |
121+
| `single_logout_service_binding` | `sp_slo_service_binding` |
122+
| `idp_sso_target_url` | `idp_sso_service_url` |
123+
| `idp_slo_target_url` | `idp_slo_service_url` |
94124

95125
## Updating from 1.12.x to 1.13.0
96126

@@ -189,7 +219,7 @@ other SAML implementations.
189219
## Upgrading from 1.4.2 to 1.4.3
190220

191221
Version `1.4.3` introduces Recipient validation of SubjectConfirmation elements.
192-
The 'Recipient' value is compared with the settings.assertion_consumer_service_url
222+
The 'Recipient' value is compared with the settings.sp_assertion_consumer_service_url
193223
value.
194224

195225
If you want to skip that validation, add the :skip_recipient_check option to the

lib/ruby_saml/authrequest.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ def create_xml_document(settings)
123123
root.attributes['ForceAuthn'] = settings.force_authn unless settings.force_authn.nil?
124124

125125
# Conditionally defined elements based on settings
126-
unless settings.assertion_consumer_service_url.nil?
127-
root.attributes["AssertionConsumerServiceURL"] = settings.assertion_consumer_service_url
126+
unless settings.sp_assertion_consumer_service_url.nil?
127+
root.attributes["AssertionConsumerServiceURL"] = settings.sp_assertion_consumer_service_url
128128
end
129129

130130
unless settings.sp_entity_id.nil?

lib/ruby_saml/logging.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def logger
2424
end
2525

2626
def deprecate(message)
27-
warn("[DEPRECATION] RubySaml: #{message}")
27+
warn("[RubySaml] DEPRECATION: #{message}")
2828
end
2929

3030
def enabled?

lib/ruby_saml/metadata.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ def add_sp_certificates(sp_sso, settings)
7777
end
7878

7979
def add_sp_service_elements(sp_sso, settings)
80-
if settings.single_logout_service_url
80+
if settings.sp_slo_service_url
8181
sp_sso.add_element "md:SingleLogoutService", {
82-
"Binding" => settings.single_logout_service_binding,
83-
"Location" => settings.single_logout_service_url,
84-
"ResponseLocation" => settings.single_logout_service_url
82+
"Binding" => settings.sp_slo_service_binding,
83+
"Location" => settings.sp_slo_service_url,
84+
"ResponseLocation" => settings.sp_slo_service_url
8585
}
8686
end
8787

@@ -90,10 +90,10 @@ def add_sp_service_elements(sp_sso, settings)
9090
nameid.text = settings.name_identifier_format
9191
end
9292

93-
if settings.assertion_consumer_service_url
93+
if settings.sp_assertion_consumer_service_url
9494
sp_sso.add_element "md:AssertionConsumerService", {
95-
"Binding" => settings.assertion_consumer_service_binding,
96-
"Location" => settings.assertion_consumer_service_url,
95+
"Binding" => settings.sp_assertion_consumer_service_binding,
96+
"Location" => settings.sp_assertion_consumer_service_url,
9797
"isDefault" => true,
9898
"index" => 0
9999
}

lib/ruby_saml/response.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,10 @@ def validate_destination
636636
return append_error(error_msg)
637637
end
638638

639-
return true if settings.assertion_consumer_service_url.nil? || settings.assertion_consumer_service_url.empty?
639+
return true if settings.sp_assertion_consumer_service_url.nil? || settings.sp_assertion_consumer_service_url.empty?
640640

641-
unless RubySaml::Utils.uri_match?(destination, settings.assertion_consumer_service_url)
642-
error_msg = "The response was received at #{destination} instead of #{settings.assertion_consumer_service_url}"
641+
unless RubySaml::Utils.uri_match?(destination, settings.sp_assertion_consumer_service_url)
642+
error_msg = "The response was received at #{destination} instead of #{settings.sp_assertion_consumer_service_url}"
643643
return append_error(error_msg)
644644
end
645645

@@ -778,7 +778,7 @@ def validate_subject_confirmation
778778
next if (attrs.include? "InResponseTo" and attrs['InResponseTo'] != in_response_to) ||
779779
(attrs.include? "NotBefore" and now < (parse_time(confirmation_data_node, "NotBefore") - allowed_clock_drift)) ||
780780
(attrs.include? "NotOnOrAfter" and now >= (parse_time(confirmation_data_node, "NotOnOrAfter") + allowed_clock_drift)) ||
781-
(attrs.include? "Recipient" and !options[:skip_recipient_check] and settings and attrs['Recipient'] != settings.assertion_consumer_service_url)
781+
(attrs.include? "Recipient" and !options[:skip_recipient_check] and settings and attrs['Recipient'] != settings.sp_assertion_consumer_service_url)
782782

783783
valid_subject_confirmation = true
784784
break

0 commit comments

Comments
 (0)