Skip to content

CurrentSecurityContextArgumentResolver should match on SecurityContext alone #13425

Closed
@jzheaux

Description

@jzheaux

To get the current security context in a Spring MVC handler method, one needs to use the @CurrentSecurityContext annotation like so:

@GetMapping
public String method(@CurrentSecurityContext SecurityContext context) { ... {

This is particularly useful when using the expression feature like the following:

@GetMapping
public String method(@CurrentSecurityContext(expression="authentication.name") String name) { ... {

But when I just need the SecurityContext, it's unnecessary boilerplate. It would be nice if the argument resolver also matched directly on the SecurityContext type so that one could do:

@GetMapping
public String method(SecurityContext context) { ... {

This change would need to be made in both the servlet and reactive argument resolvers.

Metadata

Metadata

Labels

in: webAn issue in web modules (web, webmvc)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions