-
-
Notifications
You must be signed in to change notification settings - Fork 591
Refactor the OneLogin::RubySaml::Metadata class #602
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
Changes from 4 commits
25160fe
b0a8834
a33e9d7
b82fc60
deaf112
cc295ea
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 |
|---|---|---|
|
|
@@ -161,10 +161,10 @@ def sign_document(private_key, certificate, signature_method = RSA_SHA1, digest_ | |
| # add the signature | ||
| issuer_element = self.elements["//saml:Issuer"] | ||
| if issuer_element | ||
| self.root.insert_after issuer_element, signature_element | ||
| self.root.insert_after(issuer_element, signature_element) | ||
| else | ||
| if sp_sso_descriptor = self.elements["/md:EntityDescriptor"] | ||
| self.root.insert_before sp_sso_descriptor, signature_element | ||
| if sp_sso_descriptor = self.elements["/md:EntityDescriptor/md:SPSSODescriptor"] | ||
| self.root.insert_before(sp_sso_descriptor, signature_element) | ||
|
Collaborator
Author
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. @pitbulk the code as I have it here is correct with what you are saying. Here's the REXML documenation: https://ruby-doc.org/stdlib-2.5.1/libdoc/rexml/rdoc/REXML/Parent.html#method-i-insert_before (It's a mystery that the previous code worked at all; it probably should have thrown an error.)
Collaborator
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. Ok, in case of md:EntitiesDescriptor Signature needs to be added as first child which is covered later... I think you are right.... maybe we could add a unittest to verify where the signature is added on the different scenarios to assure it is not break in the future. Rather than that the PR seems ok, I just had a minus comment about a refactor. Good job.
Collaborator
Author
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. In that case we should force it to always insert explicitly as the first child of
Collaborator
Author
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. I'm not an expert in REXML so I'll have to check the right way to do this. If you know offhand please let me know :)
Collaborator
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. Not an REXML expert neither ;) , that why makes sense the extra unittests
Collaborator
Author
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. Unit test added and ready for final review. Note that unit test includes In a follow-up PR we should consider to have the Metadata class itself do the XSD validation, since we're now allowing users to add custom elements and the validation is quite strict. |
||
| else | ||
| self.root.add_element(signature_element) | ||
| end | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.