Annotation Interface CurrentSecurityContext
@Target({PARAMETER,ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
public @interface CurrentSecurityContext
Annotation that is used to resolve the
SecurityContext as a method argument.- Since:
- 5.2
See: CurrentSecurityContextArgumentResolver For Servlet
See: CurrentSecurityContextArgumentResolver For WebFlux
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanTrue if aClassCastExceptionshould be thrown when the currentSecurityContextis the incorrect type.If specified, will use the provided SpEL expression to resolve the security context.
-
Element Details
-
errorOnInvalidType
boolean errorOnInvalidTypeTrue if aClassCastExceptionshould be thrown when the currentSecurityContextis the incorrect type. Default is false.- Returns:
- whether or not to error on an invalid type
- Default:
- false
-
expression
String expressionIf specified, will use the provided SpEL expression to resolve the security context. This is convenient if applications need to transform the result. For example, if an application needs to extract its customAuthenticationimplementation, then it could specify the appropriate SpEL like so:@CurrentSecurityContext(expression = "authentication") CustomAuthentication authentication
- Returns:
- the expression to use
- Default:
- ""
-