You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Method Security expressions that use templates do not use deep non-aliased attributes. A complete sample can be found in my sample repository, but is highlighted below:
@ServicepublicclassAuthz {
publicbooleanhasPermission(Authenticationauthentication, Objectobject, Stringpermission) {
returntrue;
}
}
@Documented@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@PreAuthorize("@authz.hasPermission(authentication, {object}, {permission})")
public @interface HasPermission {
Stringobject();
Stringpermission();
}
@Documented@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD})
@HasPermission(object = "{value}", permission = "'read'")
public @interface HasReadPermission {
// If the alias is used, then Spring Security does work. However, there may be templates where a new variable is introduced and thus nothing to alias// @AliasFor(annotation = HasPermission.class, value = "object")Stringvalue();
}
@ServicepublicclassMessageService {
@HasReadPermission("#name")
StringsayHello(Stringname) {
return"Hello " + name;
}
}
This will produce the error Failed to evaluate expression '@authz.hasPermission(authentication, {value}, 'read')'.
I'd expect the expression to replace {value} with #name.
The text was updated successfully, but these errors were encountered:
Method Security expressions that use templates do not use deep non-aliased attributes. A complete sample can be found in my sample repository, but is highlighted below:
This will produce the error
Failed to evaluate expression '@authz.hasPermission(authentication, {value}, 'read')'
.I'd expect the expression to replace
{value}
with#name
.The text was updated successfully, but these errors were encountered: