- 
                Notifications
    You must be signed in to change notification settings 
- Fork 11
Implement signed AuthnRequests #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -20,18 +20,35 @@ def body | |
|  | ||
| # Utility method to get the full redirect destination, Request#url("https://idp.example.com/saml", { :RelayState => "https://sp.example.com/saml" }) | ||
| def url(root, params = {}) | ||
| dest = root.dup | ||
| if dest.include?("?") | ||
| dest << "&SAMLRequest=#{param}" | ||
| else | ||
| dest << "?SAMLRequest=#{param}" | ||
| params = params.dup | ||
| buffer = root.dup | ||
| buffer << (buffer.include?("?") ? "&" : "?") | ||
|  | ||
| signable = "SAMLRequest=#{param}" | ||
|  | ||
| if params[:RelayState] | ||
| signable << "&RelayState=#{CGI.escape(params.delete(:RelayState))}" | ||
| end | ||
|  | ||
| if options[:sign_requests] | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. | ||
| signable << "&SigAlg=#{CGI.escape('http://www.w3.org/2000/09/xmldsig#rsa-sha1')}" | ||
| signable << "&Signature=#{CGI.escape(compute_signature(signable))}" | ||
| end | ||
|  | ||
| buffer << signable | ||
|  | ||
| params.each_pair do |key, value| | ||
| dest << "&#{key}=#{CGI.escape(value.to_s)}" | ||
| buffer << "&#{key}=#{CGI.escape(value.to_s)}" | ||
| end | ||
|  | ||
| dest | ||
| buffer | ||
| end | ||
|  | ||
| private | ||
| def compute_signature(signable) | ||
| certificate = options[:signing_certificate] #instance of Samlr::Tools::CertificateBuilder | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make sure this exists in  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, Ill see what I can do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even an  | ||
| certificate.sign(signable) | ||
| end | ||
|  | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to dup the params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
params is mutated a few lines down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.delete, yep. good call.