-
Notifications
You must be signed in to change notification settings - Fork 6k
Add HSM Support for Decrypting Assertions #9055
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
Conversation
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.
Thanks, @ryan13mt, for another PR! I've left some feedback inline.
...framework/security/saml2/provider/service/authentication/OpenSamlAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
...framework/security/saml2/provider/service/authentication/OpenSamlAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
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.
Thanks for the updates, @ryan13mt! I like where this is headed; I've left some feedback inline.
Also, just a reminder to add tests for the setters. I believe it would suffice to use mock Consumer
instances.
@@ -211,6 +211,32 @@ | |||
|
|||
private Converter<Saml2AuthenticationToken, Decrypter> decrypterConverter = new DecrypterConverter(); | |||
|
|||
private Decrypter decrypter; |
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.
This isn't thread-safe. Because the decrypter
instance is changed with each authentication, two concurrent authentication attempts will clobber each other's value here.
Instead, the default values below will need to construct a Decrypter
using the details from Saml2AuthenticationToken
. For assertionDecrypter
, I think this will look something like:
Decrypter decrypter = this.decrypterConverter.convert(responseToken.getToken());
for (EncryptedAssertion encryptedAssertion : responseToken.getResponse().getEncryptedAssertions()) {
// ...
with something similar being done in principalDecrypter
.
@@ -407,6 +477,14 @@ public boolean supports(Class<?> authentication) { | |||
return authentication != null && Saml2AuthenticationToken.class.isAssignableFrom(authentication); | |||
} | |||
|
|||
private Consumer<ResponseToken> getAssertionDecrypter() { |
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.
To simplify the code, I recommend removing these getters and having the code refer directly to the fields.
...framework/security/saml2/provider/service/authentication/OpenSamlAuthenticationProvider.java
Show resolved
Hide resolved
@jzheaux locally this is failing as well like the other pull request. Not really sure on what the reason is. Execution failed for task ':spring-security-samples-boot-oauth2resourceserver-webflux:integrationTest' |
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.
Thanks for the updates, @ryan13mt! In preparation for merging, will you please squash your commits? Also, if you like, please consider adding yourself to the list of authors.
Thanks @jzheaux hope i squashed my commits the right way. Is there anything else needed to close this PR please? Also i noticed this is not linked to the issue yet. |
Thanks for your contribution, @ryan13mt! This is now merged into In a few minutes, it should be available in |
Hello @jzheaux thanks for closing this issue and merging to master. I am finding a problem with the polishing commit. You added a check in d0581c9#diff-e1434c9a229d033aa3fe922ab7b9637a54ba5a2521711e3b362e70bc7f787833R511 where you are checking if a response is signed and if true, doing the elements decryption. Is there a reason this check was added? I believe this is not correct since there are use cases where the idp will sign and encrypt the assertion but will leave the response unsigned as is in our case. Thus having an unsigned SAML Response with an encrypted signed Assertion should still decrypt the assertion and then checking that it has been signed before throwing the error With this new check, the library is now requiring that a response must be signed if it contains an encrypted assertion. Thanks |
To solve issue: #9044