I have the following implementation of MethodSecurityExpressionOperations
public class CustomMethodSecurityExpressionRoot extends SecurityExpressionRoot implements MethodSecurityExpressionOperations {
private Object filterObject;
private Object returnObject;
CustomMethodSecurityExpressionRoot(Authentication authentication) {
super(authentication);
}
public boolean isTeamMember(Job job) {
//very interesting logic
}
@Override
public Object getFilterObject() {
return this.filterObject;
}
@Override
public Object getReturnObject() {
return this.returnObject;
}
@Override
public Object getThis() {
return this;
}
@Override
public void setFilterObject(Object obj) {
this.filterObject = obj;
}
@Override
public void setReturnObject(Object obj) {
this.returnObject = obj;
}
}
As you can see I have custom defined method called isTeamMember. This method is successfully evaluated by the following pre authorize annotation: @PreAuthorize("isTeamMember(#job)") but unfortunately it is not resolved as the Spring SpEL function.
Is there any Spring Bootish automagic way to register isTeamMember as SPeL function?