In a Spring MVC application using Sitemesh to decorate my views, I want to inject into every Model
a security attribute called sec of type WebSecurityExpressionRoot
.
This way I could call hasAnyRole(), hasAuthority()... in all my views so administrators would be presented extra stuff by the underlying templating engine (Thymeleaf BTW).
A custom HandlerInterceptorAdapter
with an overridden postHandle(...) seems to be Spring MVC's way of accomplishing this, but it seems that my master Sitemesh decorator is kind of stealing my security attribute, because whenever I try to reference in some views it is null.
BUT only the views rendered after one of my controllers are affected, the ones
mapped with mvc:view-controller
do have the sec attribute.
I'm considering writing a Filter
to stash sec into the current HttpServletRequest
to solve this issue but I'm maybe missing something.
Thanks in advance!