Skip to content

Commit

Permalink
Merge pull request SAML-Toolkits#67 from newrelic/add_destination_att…
Browse files Browse the repository at this point in the history
…ribute

Added the Destination attribute to the AuthnRequest
  • Loading branch information
stouset committed Feb 11, 2013
2 parents 5cbac3d + 048c0b5 commit 87ccc49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/onelogin/ruby-saml/authrequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def create_authentication_xml_doc(settings)
root.attributes['ID'] = uuid
root.attributes['IssueInstant'] = time
root.attributes['Version'] = "2.0"
root.attributes['Destination'] = settings.idp_sso_target_url unless settings.idp_sso_target_url.nil?

# Conditionally defined elements based on settings
if settings.assertion_consumer_service_url != nil
Expand Down
15 changes: 15 additions & 0 deletions test/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ class RequestTest < Test::Unit::TestCase
assert_match /^<samlp:AuthnRequest/, inflated
end

should "create the deflated SAMLRequest URL parameter including the Destination" do
settings = Onelogin::Saml::Settings.new
settings.idp_sso_target_url = "http://example.com"
auth_url = Onelogin::Saml::Authrequest.new.create(settings)
payload = CGI.unescape(auth_url.split("=").last)
decoded = Base64.decode64(payload)

zstream = Zlib::Inflate.new(-Zlib::MAX_WBITS)
inflated = zstream.inflate(decoded)
zstream.finish
zstream.close

assert_match /<samlp:AuthnRequest[^<]* Destination='http:\/\/example.com'/, inflated
end

should "create the SAMLRequest URL parameter without deflating" do
settings = Onelogin::Saml::Settings.new
settings.compress_request = false
Expand Down

0 comments on commit 87ccc49

Please sign in to comment.