Skip to content
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

Pass options with :get_params to signature validation #50

Closed
wants to merge 3 commits into from

Conversation

pkarman
Copy link
Contributor

@pkarman pkarman commented Jul 16, 2016

The RubySaml lib supports signature validation via GET params as well as embedded within the XML document itself. This PR adds similar support, especially for Logout requests, where signature is necessary to prevent cross-site attacks.

@jphenow jphenow self-assigned this Jul 18, 2016
def valid_signature?(fingerprint)
signed? &&
signed_document.validate(fingerprint, :soft)
def options_have_signature(options)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems slightly unnecessary as a separate method, or at least unnecessary as a public method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Marked as private in 381640e

I made it a method to avoid having a really long line with mixed booleans.

@jphenow
Copy link
Collaborator

jphenow commented Jul 18, 2016

It seems we took a relatively single-entry interface and just added "options" - is there a way we could solve this without passing ambiguous options all the way down and changing the signature of a string of methods?

For instance, perhaps we accept options at the top, convert the inputs into something relatively consistent (perhaps even put a class in between to make things easier to access consistently) then return to business as usual

@pkarman
Copy link
Contributor Author

pkarman commented Jul 18, 2016

I agree that it would have been preferable to not change so many method signatures. The dilemma is that the class that really requires a change is XMLSecurity -- ironically, a fork of the same class that ruby-saml also forked.

XMLSecurity is used only internally, mostly for validating signatures. In order to pass the signature pieces down to that level, I found it necessary to change all the methods that lead down to it.

I followed the pattern in ruby-saml:
https://github.com/onelogin/ruby-saml/blob/master/lib/onelogin/ruby-saml/logoutresponse.rb#L32
https://github.com/onelogin/ruby-saml/blob/master/lib/onelogin/ruby-saml/logoutresponse.rb#L204

@pkarman
Copy link
Contributor Author

pkarman commented Jul 19, 2016

@jphenow I'd be happy to try a different approach for this; I'm just honestly not sure how. The architecture of the lib puts all the signature checking in an internal-only class. The ruby-saml lib architecture puts the signature checking in an external Utils class. Maybe that approach works better here?

@pkarman
Copy link
Contributor Author

pkarman commented Jul 20, 2016

There's a related discussion here: SAML-Toolkits/python-saml#153 (comment)

Note that when using DEFLATE in a SAMLRequest (as SamlIdp.from_deflated_request assumes), then the request must pass the signature in the query parameters. So it makes sense to me that the SamlIdp.from_deflated_request method accept query parameters .

@@ -24,7 +24,7 @@ def validate_saml_request(raw_saml_request = params[:SAMLRequest])
end

def decode_request(raw_saml_request)
self.saml_request = Request.from_deflated_request(raw_saml_request)
self.saml_request = Request.from_deflated_request(raw_saml_request, get_params: params)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request.GET

@jphenow
Copy link
Collaborator

jphenow commented Jul 25, 2016

Thinking on this one.. I have some ideas, I may pull the feature you're looking for and use it as an opportunity for a minor restructure. I'll come back with something soon

@jnardone
Copy link

@jphenow are you still thinking on this one? Or is this something that is going to see the light of day?

@jphenow
Copy link
Collaborator

jphenow commented Mar 19, 2018

I'm not actively overseeing this project at the moment and would rather not step on those that are now caring for it.

@mvastola how do you feel about these changes?

@pkarman
Copy link
Contributor Author

pkarman commented May 17, 2019

assuming 18F fork is the relevant one now.

@pkarman pkarman closed this May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants