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

SecurityExpressionHandler#createEvaluationContext should defer lookup of Authentication #9667

Closed
jzheaux opened this issue Apr 21, 2021 · 3 comments · Fixed by #11187
Closed
Assignees
Labels
in: core An issue in spring-security-core type: breaks-passivity A change that breaks passivity with the previous release type: enhancement A general enhancement
Milestone

Comments

@jzheaux
Copy link
Contributor

jzheaux commented Apr 21, 2021

Like AuthorizationManager, it would be nice to be able to defer the looking up Authentication in SecurityExpressionHandler.

A default createEvaluationContext method could be added:

default EvaluationContext createEvaluationContext(Supplier<Authentication> authentication, T invocation) {
    return createEvaluationContext(authentication.get(), invocation);
}

And then DefaultXXXSecurityExpressionHandlers would be updated to defer evaluation until the authentication was inspected.

@jzheaux jzheaux added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Apr 21, 2021
@jzheaux jzheaux added in: core An issue in spring-security-core and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 26, 2021
@jzheaux jzheaux modified the milestone: 6.x Apr 26, 2021
@rwinch rwinch added this to the 5.6.x milestone Apr 28, 2021
@evgeniycheban
Copy link
Contributor

@jzheaux I can take this.

@evgeniycheban
Copy link
Contributor

@jzheaux I've opened the PR, please take a look.

evgeniycheban added a commit to evgeniycheban/spring-security that referenced this issue May 18, 2022
- Added createEvaluationContext method that accepts Supplier<Authentication>
- Refactored classes that use EvaluationContext to use lazy initialization of Authentication

Closes spring-projectsgh-9667
@jzheaux jzheaux added the type: breaks-passivity A change that breaks passivity with the previous release label May 18, 2022
@jzheaux
Copy link
Contributor Author

jzheaux commented May 18, 2022

In order to accommodate changing to Supplier<Authentication> in SecurityExpressionRoot, the protected Authentication authentication member variable is changed to private Supplier<Authentication> authentication.

Classes that extend SecurityExpressionRoot and access the protected member variable should instead call getAuthentication().

jzheaux pushed a commit that referenced this issue May 18, 2022
- Added createEvaluationContext method that accepts Supplier<Authentication>
- Refactored classes that use EvaluationContext to use lazy initialization of Authentication

Closes gh-9667
jzheaux added a commit that referenced this issue May 23, 2022
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: breaks-passivity A change that breaks passivity with the previous release type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants