Skip to content

Add OneTimeUse support for SAML assertions#19144

Open
therepanic wants to merge 1 commit intospring-projects:mainfrom
therepanic:gh-19130
Open

Add OneTimeUse support for SAML assertions#19144
therepanic wants to merge 1 commit intospring-projects:mainfrom
therepanic:gh-19130

Conversation

@therepanic
Copy link
Copy Markdown
Contributor

This change will allow us to add <OneTimeUse> elements out of the box. To do this, we can pass the cache through
OpenSaml5AuthenticationProvider.AssertionValidator.Builder#replayCache and add the condition itself directly when building the builder. I also created a package-private SpringCacheReplayCache that implements ReplayCache and is needed to work with the constructor of OneTimeUseConditionValidator.

Closes: gh-19130

This change will allow us to add `<OneTimeUse>` elements out of the box.
To do this, we can pass the cache through
`OpenSaml5AuthenticationProvider.AssertionValidator.Builder#replayCache`
and add the condition itself directly when building the builder. I also
created a package-private `SpringCacheReplayCache` that implements
`ReplayCache` and is needed to work with the constructor of
`OneTimeUseConditionValidator`.

Closes: spring-projectsgh-19130

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
Comment on lines 747 to 748
this.conditions.add(new DelegationRestrictionConditionValidator());
this.conditions.add(new ValidConditionValidator(OneTimeUse.DEFAULT_ELEMENT_NAME));
this.conditions.add(new ProxyRestrictionConditionValidator());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how validation works, I don't think it would be a bad idea to move the logic for adding OneTimeUse.DEFAULT_ELEMENT_NAME into the build method itself

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 2, 2026
Comment on lines 846 to +851
public AssertionValidator build() {
if (this.replayCache != null) {
this.conditions
.add(new OneTimeUseConditionValidator(new SpringCacheReplayCache(this.replayCache), null));
}
else {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can afford to ignore null since we set the duration manually in SpringCacheReplayCache#check?

@therepanic
Copy link
Copy Markdown
Contributor Author

I left a couple of comments on topics that interest me, PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add OneTimeUse support for SAML assertions

2 participants