Skip to content

Commit 220d9be

Browse files
author
James Edwards-Jones
committed
feat: allow request uuid to be stored
Introduces a :store_request_uuid option for later comparison with InResponseTo By default it saves the request uuid in the session as "saml_transaction_id", but also accepts a proc that will then be called with the uuid for custom storage.
1 parent a0eedd6 commit 220d9be

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ Note that when [integrating with Devise](#devise-integration), the URL path will
143143

144144
* `:uid_attribute` - Attribute that uniquely identifies the user. If unset, the name identifier returned by the IdP is used.
145145

146+
* `:store_request_uuid` - Used to store the request's UUID for later verification of InReponseTo.
147+
By default it saves the request uuid in the session as "saml_transaction_id",
148+
but also accepts a proc that will then be called with the uuid for custom storage.
149+
146150
* See the `OneLogin::RubySaml::Settings` class in the [Ruby SAML gem](https://github.com/onelogin/ruby-saml) for additional supported options.
147151

148152
## IdP Metadata

lib/omniauth/strategies/saml.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,26 @@ def self.inherited(subclass)
3030
option :slo_default_relay_state
3131
option :uid_attribute
3232
option :idp_slo_session_destroy, proc { |_env, session| session.clear }
33+
option :store_request_uuid
3334

3435
def request_phase
3536
authn_request = OneLogin::RubySaml::Authrequest.new
3637

38+
store_request_uuid(authn_request.uuid)
39+
3740
with_settings do |settings|
3841
redirect(authn_request.create(settings, additional_params_for_authn_request))
3942
end
4043
end
4144

45+
def store_request_uuid(uuid)
46+
if options.store_request_uuid.respond_to?(:call)
47+
options.store_request_uuid.call(uuid)
48+
elsif options.store_request_uuid
49+
session["saml_transaction_id"] = uuid
50+
end
51+
end
52+
4253
def callback_phase
4354
raise OmniAuth::Strategies::SAML::ValidationError.new("SAML response missing") unless request.params["SAMLResponse"]
4455

0 commit comments

Comments
 (0)