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

Default use of RequestAttributeSecurityContextRepository instead of NullSecurityContextRepository #11026

Closed
rwinch opened this issue Mar 25, 2022 · 2 comments
Assignees
Labels
in: web An issue in web modules (web, webmvc) type: breaks-passivity A change that breaks passivity with the previous release type: enhancement A general enhancement
Milestone

Comments

@rwinch
Copy link
Member

rwinch commented Mar 25, 2022

Rather than totally ignoring saving the SecurityContext we should place it on the request as a request attribute to ensure that other dispatch types work properly.

Related gh-10918

@rwinch rwinch added in: web An issue in web modules (web, webmvc) type: enhancement A general enhancement type: breaks-passivity A change that breaks passivity with the previous release labels Mar 25, 2022
@rwinch rwinch added this to the 6.0.0-M4 milestone Mar 25, 2022
@rwinch rwinch changed the title Default Replace NullSecurityContextRepository with RequestAttributeSecurityContextRepository Default use of RequestAttributeSecurityContextRepository instead of NullSecurityContextRepository Mar 25, 2022
@sjohnr sjohnr modified the milestones: 6.0.0-M4, 6.0.0-M5, 6.0.0-M6 May 16, 2022
@akovalyev
Copy link

akovalyev commented Jun 1, 2022

How to use RequestAttributeSecurityContextRepository if it doesn't create SecurityContextHolder.createEmptyContext() because RequestAttributeSecurityContextRepository#loadContext(HttpServletRequest) is called instead of loadContext(HttpRequestResponseHolder); and an exception will be thrown if the SecurityContextHolderFilter calls SecurityContextHolder.setContext(null):
"Only non-null SecurityContext instances are allowed"?

Expect loadContext(HttpServletRequest) to return SecurityContextHolder.createEmptyContext() if request.getAttribute() == null

Reproduced at https://github.com/spring-projects/spring-security/releases/tag/5.7.1

@marcusdacoregio
Copy link
Contributor

Hi @akovalyev, I think that your scenario is a bug, I create this ticket to track that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) type: breaks-passivity A change that breaks passivity with the previous release type: enhancement A general enhancement
Projects
Archived in project
Development

No branches or pull requests

4 participants