-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Expected Behavior
Ideally I would be able to create a default assertion validator via createDefaultAssertionValidator()
and be able to pass a set of static parameters for the default ValidationContext
.
Current Behavior
Currently, I can create a ValidationContext
with static parameters OR create a default ValidationContext
, not both (with one caveat, see Context).
Context
Let's say I want to create an assertion validator (Converter<AssertionToken, Saml2ResponseValidatorResult>
) that has a custom clock skew parameter associated with the validator's ValidationContext
. I can call OpenSaml4AuthenticationProvider.createDefaultAssertionValidator(Converter<AssertionToken, ValidationContext> contextConverter)
:
authenticationProvider.setAssertionValidator(
OpenSaml4AuthenticationProvider.createDefaultAssertionValidator(assertionToken -> {
params.put(SAML2AssertionValidationParameters.CLOCK_SKEW, Duration.ofSeconds(100l);
return new ValidationContext(params);
}));
The created ValidationContext
will only check CLOCK_SKEW
, not other important parameters like COND_VALID_AUDIENCES
or SC_VALID_RECIPIENTS
, because OpenSaml4AuthenticationProvider.createDefaultAssertionValidator(Converter<AssertionToken, ValidationContext> contextConverter)
does not let me append to or overwrite the default static parameters, which are defined in the private method OpenSaml4AuthenticationProvider.createValidationContext()
I could of course call OpenSaml4AuthenticationProvider.createDefaultAssertionValidator()
, which has a hardcoded CLOCK_SKEW
parameter of 5 minutes and then use Saml2ResponseValidatorResult.concat()
to add my 100 second CLOCK_SKEW check, but what if I really wanted clock skew to be 6 minutes? The initial hardcoded check would cause a validation failure to occur. If I really, really wanted this 6 minute clock skew I would have to call OpenSaml4AuthenticationProvider.createDefaultAssertionValidator(Converter<AssertionToken, ValidationContext> contextConverter)
, copy in all the logic from OpenSaml4AuthenticationProvider.createValidationContext()
, and change the clock skew parameter.
It's a contrived example but the root issue is that there's no way to call createValidationContext(AssertionToken assertionToken, Consumer<Map<String, Object>> paramsConsumer)
. This would make life so much easier -- I could reuse the existing logic to create a default ValidationContext
and, say, change the value associated with SC_VALID_RECIPIENTS
, SC_VALID_IN_RESPONSE_TO
, CLOCK_SKEW
, etc. without affecting any of the other static parameters.