use of org.springframework.data.spel.spi.EvaluationContextExtension in project CzechIdMng by bcvsolutions.
the class WebSecurityConfig method securityExtension.
/**
* Support hasAuthority etc. in search queries
*
* @return
*/
@Bean
public EvaluationContextExtension securityExtension() {
return new EvaluationContextExtension() {
@Override
public String getExtensionId() {
return "security";
}
@Override
public SecurityExpressionRoot getRootObject() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
// not authenticated
return null;
}
SecurityExpressionRoot root = new SecurityExpressionRoot(authentication) {
};
root.setRoleHierarchy(roleHierarchy);
return root;
}
};
}
Aggregations