Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/saml/bindings/http_redirect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class HTTPRedirect

class << self
def create_url(request_or_response, options = {})
options[:signature_algorithm] ||= 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'
options[:signature_algorithm] ||= 'http://www.w3.org/2000/09/xmldsig#rsa-sha1' unless options[:exclude_signature]
new(request_or_response, options).create_url
end

Expand Down Expand Up @@ -42,13 +42,14 @@ def decode_message(message)
end
end

attr_accessor :request_or_response, :signature_algorithm, :relay_state, :signature
attr_accessor :request_or_response, :signature_algorithm, :relay_state, :signature, :exclude_signature

def initialize(request_or_response, options = {})
@request_or_response = request_or_response
@signature_algorithm = options[:signature_algorithm]
@relay_state = options[:relay_state]
@signature = options[:signature]
@exclude_signature = options[:exclude_signature]
end

def verify_signature(query)
Expand All @@ -61,7 +62,7 @@ def create_url
url = request_or_response.destination
delimiter = url.include?('?') ? '&' : '?'

[url, signed_params].join(delimiter)
[url, exclude_signature ? unsigned_params : signed_params].join(delimiter)
end

private
Expand Down Expand Up @@ -108,6 +109,10 @@ def signed_params

"#{encoded_params}&Signature=#{encoded_signature}"
end

def unsigned_params
encoded_params.to_s
end
end
end
end
13 changes: 13 additions & 0 deletions spec/lib/saml/bindings/http_redirect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ def get_url(request = authn_request)
expect(params["Signature"]).to eq(sha1_signature_mri)
end
end

context "with exclude_signature option" do
let(:url) do
described_class.create_url(authn_request,
exclude_signature: true
)
end

it "not add Signature and SigAlg params" do
expect(params["Signature"]).to eq nil
expect(params["SigAlg"]).to eq nil
end
end
end
end

Expand Down