Skip to content

Method Security SpEL supports throwing AccessDeniedException #14600

Closed
@rwinch

Description

@rwinch

It would be nice if we supported throwing AccessDeniedException for Method Security SpEL. This would allow method security to easily convey more information to the framework on why authorization failed (e.g. requires MFA). They can also use AuthorizationManager instances in their SpEL. For example:

@Service
class Authz {
  AuthorizationDecision check(...) {
    throw new AccessDeniedException("Denied");
  }
}
@PreAuthorize("@authz.check(...)")

Metadata

Metadata

Assignees

Labels

in: coreAn issue in spring-security-coretype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions