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

Generalize SAML 2.0 Assertion Validation Support #8970

Closed
jzheaux opened this issue Aug 18, 2020 · 0 comments
Closed

Generalize SAML 2.0 Assertion Validation Support #8970

jzheaux opened this issue Aug 18, 2020 · 0 comments
Assignees
Labels
in: saml2 An issue in SAML2 modules type: enhancement A general enhancement
Milestone

Comments

@jzheaux
Copy link
Contributor

jzheaux commented Aug 18, 2020

Recent support for configuring OpenSAML's ConditionValidators and ValidationContext were added to OpenSamlAuthenticationProvider.

Based on some early RC1 feedback, it would be nice if the assertion validation support were more generalized.

Since delegation is a common pattern in Spring Security, it would make sense to have a setter that encouraged this practice. Also, it would be nice if the contract were more similar to OAuth2TokenValidator's. One way to do this would be to replace setConditionValidators and setValidationContextConverter with two other methods:

public void setAssertionValidator(
        Converter<AssertionToken, Saml2ResponseValidatorResult> assertionValidator);

public static Converter<AssertionToken, Saml2ResponseValidatorResult> createDefaultAssertionValidator(
        ValidationContext context);

These are similar to JwtDecoder#setJwtValidator and JwtValidators#createDefault methods.

Together, these allow an application to customize validation and delegate to Spring Security's defaults, like so:

OpenSamlAuthenticationProvider provider = new OpenSamlAuthenticationProvider();
provider.setAssertionValidator(assertionToken -> {
    ValidationContext context = ...;
    Saml2ResponseValidatorResult result =
            createDefaultAssertionValidator(context).convert(assertionToken);
    Saml2ResponseValidatorResult custom =
            myCustomValidator.convert(assertionToken);
    return result.concat(custom);
});
@jzheaux jzheaux added type: enhancement A general enhancement in: saml2 An issue in SAML2 modules labels Aug 18, 2020
@jzheaux jzheaux added this to the 5.4.0 milestone Aug 18, 2020
@jzheaux jzheaux self-assigned this Aug 18, 2020
jzheaux added a commit that referenced this issue Aug 19, 2020
In several cases, taking a pre-set ValidationContext is not sufficient.
For example, the recipient is calculated via the
RelyingPartyRegistration that's currently in the context of the
request.

Instead, then, createDefaultAssertionValidator was broken up into two
different methods: One that takes no parameters and assumes the class's
default ValidationContext, and another that takes a converter to derive
the ValidationContext from the incoming authentication token.

Issue gh-8970
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: saml2 An issue in SAML2 modules type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant