Skip to content

Commit 3229214

Browse files
authored
Merge pull request #699 from johnnyshields/settings-params-deprecations
v2.0: Settings params deprecations
2 parents 8748250 + 77dd735 commit 3229214

File tree

4 files changed

+67
-52
lines changed

4 files changed

+67
-52
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* [#686](https://github.com/SAML-Toolkits/ruby-saml/pull/686) Use SHA-256 as the default hashing algorithm everywhere instead of SHA-1, including signatures, fingerprints, and digests.
1010
* [#695](https://github.com/SAML-Toolkits/ruby-saml/pull/695) Deprecate `settings.compress_request` and `settings.compess_response` parameters.
1111
* [#690](https://github.com/SAML-Toolkits/ruby-saml/pull/690) Remove deprecated `settings.security[:embed_sign]` parameter.
12+
* [#697](https://github.com/SAML-Toolkits/ruby-saml/pull/697) Add deprecation for various parameters in `RubySaml::Settings`.
1213

1314
### 1.17.0
1415
* [#687](https://github.com/SAML-Toolkits/ruby-saml/pull/687) Add CI coverage for Ruby 3.3 and Windows.

UPGRADING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ 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
84+
85+
The following parameters in `RubySaml::Settings` are deprecated and will be removed in RubySaml 2.1.0:
86+
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`.
94+
8395
## Updating from 1.12.x to 1.13.0
8496

8597
Version `1.13.0` adds `settings.idp_sso_service_binding` and `settings.idp_slo_service_binding`, and

lib/ruby_saml/settings.rb

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def initialize(overrides = {}, keep_security_attributes = false)
3232

3333
# IdP Data
3434
attr_accessor :idp_entity_id
35-
attr_writer :idp_sso_service_url
36-
attr_writer :idp_slo_service_url
35+
attr_accessor :idp_sso_service_url
36+
attr_accessor :idp_slo_service_url
3737
attr_accessor :idp_slo_response_service_url
3838
attr_accessor :idp_cert
3939
attr_accessor :idp_cert_fingerprint
@@ -43,10 +43,11 @@ def initialize(overrides = {}, keep_security_attributes = false)
4343
attr_accessor :idp_name_qualifier
4444
attr_accessor :valid_until
4545
# SP Data
46-
attr_writer :sp_entity_id
46+
attr_accessor :sp_entity_id
4747
attr_accessor :assertion_consumer_service_url
4848
attr_reader :assertion_consumer_service_binding
49-
attr_writer :single_logout_service_url
49+
attr_accessor :single_logout_service_url
50+
attr_reader :single_logout_service_binding
5051
attr_accessor :sp_name_qualifier
5152
attr_accessor :name_identifier_format
5253
attr_accessor :name_identifier_value
@@ -68,25 +69,6 @@ def initialize(overrides = {}, keep_security_attributes = false)
6869
# Work-flow
6970
attr_accessor :security
7071
attr_accessor :soft
71-
# Deprecated
72-
attr_accessor :certificate_new
73-
attr_accessor :assertion_consumer_logout_service_url
74-
attr_reader :assertion_consumer_logout_service_binding
75-
attr_accessor :issuer
76-
attr_accessor :idp_sso_target_url
77-
attr_accessor :idp_slo_target_url
78-
79-
# @return [String] IdP Single Sign On Service URL
80-
#
81-
def idp_sso_service_url
82-
@idp_sso_service_url || @idp_sso_target_url
83-
end
84-
85-
# @return [String] IdP Single Logout Service URL
86-
#
87-
def idp_slo_service_url
88-
@idp_slo_service_url || @idp_slo_target_url
89-
end
9072

9173
# @return [String] IdP Single Sign On Service Binding
9274
#
@@ -114,12 +96,6 @@ def idp_slo_service_binding=(value)
11496
@idp_slo_service_binding = get_binding(value)
11597
end
11698

117-
# @return [String] SP Entity ID
118-
#
119-
def sp_entity_id
120-
@sp_entity_id || @issuer
121-
end
122-
12399
# Setter for SP Protocol Binding
124100
# @param value [String, Symbol].
125101
#
@@ -134,18 +110,6 @@ def assertion_consumer_service_binding=(value)
134110
@assertion_consumer_service_binding = get_binding(value)
135111
end
136112

137-
# @return [String] Single Logout Service URL.
138-
#
139-
def single_logout_service_url
140-
@single_logout_service_url || @assertion_consumer_logout_service_url
141-
end
142-
143-
# @return [String] Single Logout Service Binding.
144-
#
145-
def single_logout_service_binding
146-
@single_logout_service_binding || @assertion_consumer_logout_service_binding
147-
end
148-
149113
# Setter for Single Logout Service Binding.
150114
#
151115
# (Currently we only support "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect")
@@ -155,15 +119,6 @@ def single_logout_service_binding=(value)
155119
@single_logout_service_binding = get_binding(value)
156120
end
157121

158-
# @deprecated Setter for legacy Single Logout Service Binding parameter.
159-
#
160-
# (Currently we only support "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect")
161-
# @param value [String, Symbol]
162-
#
163-
def assertion_consumer_logout_service_binding=(value)
164-
@assertion_consumer_logout_service_binding = get_binding(value)
165-
end
166-
167122
# Calculates the fingerprint of the IdP x509 certificate.
168123
# @return [String] The fingerprint
169124
#
@@ -292,6 +247,38 @@ def get_binding(value)
292247
}.freeze
293248
}.freeze
294249

250+
{
251+
issuer: :sp_entity_id,
252+
idp_sso_target_url: :idp_sso_service_url,
253+
idp_slo_target_url: :idp_slo_service_url,
254+
assertion_consumer_logout_service_url: :single_logout_service_url,
255+
assertion_consumer_logout_service_binding: :single_logout_service_binding
256+
}.each do |old_param, new_param|
257+
# @deprecated Will be removed in v2.1.0
258+
define_method(old_param) do
259+
replaced_deprecation(old_param, new_param)
260+
send(new_param)
261+
end
262+
263+
# @deprecated Will be removed in v2.1.0
264+
define_method(:"#{old_param}=") do |value|
265+
replaced_deprecation(old_param, new_param)
266+
send(:"#{new_param}=", value)
267+
end
268+
end
269+
270+
# @deprecated Will be removed in v2.1.0
271+
def certificate_new
272+
certificate_new_deprecation
273+
@certificate_new
274+
end
275+
276+
# @deprecated Will be removed in v2.1.0
277+
def certificate_new=(value)
278+
certificate_new_deprecation
279+
@certificate_new = value
280+
end
281+
295282
# @deprecated Will be removed in v2.1.0
296283
def compress_request
297284
compress_deprecation('compress_request', 'idp_sso_service_binding')
@@ -318,6 +305,19 @@ def compress_response=(value)
318305

319306
private
320307

308+
# @deprecated Will be removed in v2.1.0
309+
def replaced_deprecation(old_param, new_param)
310+
Logging.deprecate "`RubySaml::Settings##{old_param}` is deprecated and will be removed in RubySaml 2.1.0. " \
311+
"Please set the same value to `RubySaml::Settings##{new_param}` instead."
312+
end
313+
314+
# @deprecated Will be removed in v2.1.0
315+
def certificate_new_deprecation
316+
Logging.deprecate '`RubySaml::Settings#certificate_new` is deprecated and will be removed in RubySaml v2.1.0. ' \
317+
'Please set `RubySaml::Settings#sp_cert_multi` instead. ' \
318+
'Please refer to documentation as `sp_cert_multi` has a different value type.'
319+
end
320+
321321
# @deprecated Will be removed in v2.1.0
322322
def compress_deprecation(old_param, new_param)
323323
Logging.deprecate "`RubySaml::Settings##{old_param}` is deprecated and no longer functional. " \

test/settings_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ class SettingsTest < Minitest::Test
3535

3636
it "should provide getters and settings for binding parameters" do
3737
accessors = [
38-
:protocol_binding, :assertion_consumer_service_binding,
39-
:single_logout_service_binding, :assertion_consumer_logout_service_binding
38+
:protocol_binding,
39+
:assertion_consumer_service_binding,
40+
:single_logout_service_binding,
41+
:assertion_consumer_logout_service_binding
4042
]
4143

4244
accessors.each do |accessor|

0 commit comments

Comments
 (0)