Skip to content

Commit d39e162

Browse files
committed
Merge branch 'v2.x-rework-uuid' of github.com:johnnyshields/ruby-saml into v2.x-rework-uuid
2 parents b5a7548 + b91bbc6 commit d39e162

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

UPGRADING.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,28 @@ settings.idp_slo_service_binding = :redirect
7777

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

80-
### Addition of Settings sp_uuid_prefix and removal of Utils::UUID_PREFIX
80+
### Change to message UUID prefix customization
8181

82-
By default, the `uuid` (aliased to `request_id` / `response_id`) method in `RubySaml::Authrequest`,
83-
`RubySaml::Logoutrequest`, and `RubySaml::Logoutresponse` uses the `_` character as a default prefix,
84-
for example `_a1b3c5d7-9f1e-3d5c-7b1a-9f1e3d5c7b1a`. In RubySaml, versions prior to `2.0.0`, it was
85-
possible to change this default prefix by either calling `RubySaml::Utils.set_prefix` or by mutating
82+
On SP-originated messages (`Authrequest`, `Logoutrequest`, `Logoutresponse`), RubySaml generates the
83+
`uuid` (aliased to `request_id` / `response_id`) using the `_` character as a default prefix,
84+
for example `_a1b3c5d7-9f1e-3d5c-7b1a-9f1e3d5c7b1a`. In RubySaml versions prior to `2.0.0`, it was
85+
possible to change this default prefix by either `RubySaml::Utils.set_prefix` or by mutating
8686
the `RubySaml::Utils::UUID_PREFIX` constant (which was what `.set_prefix` did.) In RubySaml `2.0.0`,
8787
this prefix is now set using `settings.sp_uuid_prefix`:
8888

8989
```ruby
9090
# Change the default prefix from `_` to `my_id_`
9191
settings.sp_uuid_prefix = 'my_id_'
92+
93+
# Create the AuthNRequest message
94+
request = RubySaml::Authrequest.new
95+
request.create(settings)
96+
request.uuid #=> "my_id_a1b3c5d7-9f1e-3d5c-7b1a-9f1e3d5c7b1a"
9297
```
9398

94-
A side-effect of this change is that the `uuid` (aliased to `request_id` / `response_id`) method in
95-
`RubySaml::Authrequest`, `RubySaml::Logoutrequest`, and `RubySaml::Logoutresponse` now is `nil` until
96-
the `#create` method is called. Previously, it was generated automatically during object instantiation.
97-
After calling `#create` for the first time the UUID will not change, even if a `Settings` object with
99+
A side-effect of this change is that the `uuid` of the `Authrequest`, `Logoutrequest`, and `Logoutresponse`
100+
classes now is `nil` until the `#create` method is called (previously, it was set in the constructor.)
101+
After calling `#create` for the first time the `uuid` will not change, even if a `Settings` object with
98102
a different `sp_uuid_prefix` is passed-in on subsequent calls.
99103

100104
### Deprecation of compression settings

lib/ruby_saml/utils.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ def generate_uuid(prefix = nil)
399399
prefix = prefix.is_a?(FalseClass) ? nil : prefix || UUID_DEFAULT_PREFIX
400400
"#{prefix}#{SecureRandom.uuid}"
401401
end
402+
# @deprecated Use #generate_uuid
402403
alias_method :uuid, :generate_uuid
403404

404405
# Given two strings, attempt to match them as URIs using Rails' parse method. If they can be parsed,

0 commit comments

Comments
 (0)