-
Notifications
You must be signed in to change notification settings - Fork 5
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
Dmm/add invalid sig errors #86
base: main
Are you sure you want to change the base?
Conversation
lib/saml_idp/request.rb
Outdated
errors.push(:invalid_signature) | ||
end | ||
rescue SamlIdp::XMLSecurity::SignedDocument::ValidationError => e | ||
errors.push(validation_error_dictionary[e.message]) |
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.
- do we need to have a default mesage here if the dictionary doesn't have a matching error?
- the dictionary keys appear to be symbols but
e.message
looks like it will be strings
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 included all possible
ValidationError
s that could pop up (and some that actually i think are impossible for us to reach, but wanted to keep them there for the moment until we refactored the code) so it didn't feel strictly necessary. happy to add a default if you disagree![ - i threw a
with_indifferent_access
in there but i can change it to the hash rockets if you'd prefer, i just think they're kind ugly!
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 didn't realize our own code threw those errors, if it's more limited that seems fine then. Maybe we just update each time we throw to have its own
error_code
property or something do we can doe.error_code
instead of a reverse lookup
So like...raise SamlIdp::XMLSecurity::SignedDocument::ValidationError.new('error message', error_code: :some_symbole_thing_here)
- I missed the
with_indifferent_access
that seems fine
lib/saml_idp/service_provider.rb
Outdated
if doc.valid_signature?(fingerprint_cert(cert), options.merge(cert: cert)) | ||
@matching_cert = cert | ||
cert | ||
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.
if we're switching to a find
, the block just needs to return true
so we can get rid of the if
and just have that condition be the body
@matching_cert = Array(certs).find do |cert|
doc.valid_signature?(fingerprint_cert(cert), options.merge(cert: cert))
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.
updated in 0d555da
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.
LGTM! Thanks for adding the error code to the error class itself!
Also don't forget to bump the gem version before merging!
f1754cc
to
0bc0aa9
Compare
0bc0aa9
to
c27da1c
Compare
expect { document.validate_doc(base64cert, false) }.to( | ||
raise_error(SamlIdp::XMLSecurity::SignedDocument::ValidationError, 'All signatures must use RSA SHA-256') | ||
) | ||
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 really want to fix the tests in this file (and spec/support/security_helpers.rb
but this scope has already gotten expanded so left a TODO in security_helpers.rb
27f8f16
to
061b51b
Compare
c813112
to
59d17eb
Compare
this PR is stale -- reference only |
This change: