Annotation Type PostAuthorize


@Retention(CLASS) @Target(METHOD) public @interface PostAuthorize

Checks an expression after the method returns, with returnObject bound to what it returned, and throws AccessDeniedException instead of returning when the expression is false, as Spring Security's annotation of the same name does.

@PostAuthorize("returnObject.owner == authentication.name or hasRole('ADMIN')")
public Document load(long id) { ... }

The expression language is PreAuthorize's. returnObject may be passed to a bean method or to hasPermission, or read through a chain of properties (returnObject.owner.name), which the build resolves to public getters or fields of the declared return type. The method has already run, so a transaction it ran in has committed by the time access is refused.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The expression.
  • Element Details

    • value

      String value
      The expression.