Skip to content

Add AllRequiredFactorsAuthorizationManager.anyOf#18997

Merged
rwinch merged 2 commits intospring-projects:mainfrom
evgeniycheban:gh-18960
Mar 31, 2026
Merged

Add AllRequiredFactorsAuthorizationManager.anyOf#18997
rwinch merged 2 commits intospring-projects:mainfrom
evgeniycheban:gh-18960

Conversation

@evgeniycheban
Copy link
Copy Markdown
Contributor

Closes gh-18960

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 27, 2026
@rwinch rwinch self-assigned this Mar 30, 2026
@rwinch rwinch added in: core An issue in spring-security-core type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 30, 2026
Copy link
Copy Markdown
Contributor

@ziqin ziqin left a comment

Choose a reason for hiding this comment

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

It is worth consideration whether we should deduplicate errors caused by RequiredFactors sharing the same authority but having different validDurations.

Comment on lines +55 to +63
/**
* Creates an {@link AuthorizationManager} that grants access if at least one
* {@link AllRequiredFactorsAuthorizationManager} granted, collects
* {@link RequiredFactorError}s omitting duplicate errors of the same factor.
* @param <T> the type of object that is being authorized
* @param managers the {@link AllRequiredFactorsAuthorizationManager}s to use
* @return the {@link AuthorizationManager} to use
* @since 7.1
*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would you consider adding a @see tag in the Javadoc of AuthorizationManagers#anyOf(AuthorizationManager...) to remind users of the existence of this method?

@evgeniycheban
Copy link
Copy Markdown
Contributor Author

It is worth consideration whether we should deduplicate errors caused by RequiredFactors sharing the same authority but having different validDurations.

I also thought about that, and it's a really valid point, let's wait what @rwinch thinks about it.

evgeniycheban and others added 2 commits March 31, 2026 13:25
Closes spring-projectsgh-18960

Signed-off-by: Evgeniy Cheban <mister.cheban@gmail.com>
- Add validation
- Extract to static inner class
- Uniqueness determined by Set rather than requiredFactor
  This is important for the failure with the same RequiredFactor, but a
  different reason
- Add documentation

Signed-off-by: Robert Winch <362503+rwinch@users.noreply.github.com>
@rwinch rwinch enabled auto-merge March 31, 2026 19:04
@rwinch rwinch merged commit 5fe29f9 into spring-projects:main Mar 31, 2026
7 checks passed
@rwinch
Copy link
Copy Markdown
Member

rwinch commented Mar 31, 2026

Thanks for the contribution @evgeniycheban I've merged the PR along with some polish into main. In response to uniqueness by the requiredFactory, I did change this to be based upon the a Set to take into account the other members on RequiredFactor.

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

Labels

in: core An issue in spring-security-core type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add AllRequiredFactorsAuthorizationManager.anyOf

4 participants