spring security - SpringBoot SpringSecurity ACL @PostFilter -
i using ...
springbootversion = '1.2.4.release' springversion = '4.1.6.release' springsecurityversion = '4.0.0.m2' @configuration @enableglobalmethodsecurity(prepostenabled = true) @enablewebmvcsecurity @profile(elmprofile.has_authentication) public class securityxxx extends websecurityconfigureradapter { }
application.java has appropriate
@componentscan logging.level.org.springframework.security=trace
problem: there strange behaviour ...
there may post filter annotations defined on service interface , in logs shows detected annotation on service impl class instead !?. althought there many such methods on service interface 1 method detected
yes service has @service annotation shown below :
@validated public interface siteservice { @postfilter("haspermission(filterobject, 'read')") @notnull list<site> getsiteswithbins(); @postfilter("haspermission(filterobject, 'read')") @notnull list<site> getallsitesrestricted(); @postfilter("haspermission(filterobject, 'read')") @notnull list<site> getallsites(); @postfilter("haspermission(filterobject, 'read')") @notnull list<site> findsitesbymain(final boolean ismain); @notnull list<site> getsitesbytransfertype(@min(1) final long siteid, @notnull final transfertype.code transfertype); @postfilter("haspermission(filterobject, 'read')") site getsite(@min(1) final long siteid); @service @transactional @requiredargsconstructor(onconstructor = @__(@autowired)) public class siteserviceimpl implements siteservice { //implementas service interface methods } stack trace below shows 1 method found , methods not found i.e. @postfilter on getsite() method found .. 2015-06-26 19:23:17.986 trace 13561 --- [ main] .prepostannotationsecuritymetadatasource : looking pre/post annotations method 'getsite' on target class 'class au.com.xxx.xxxx.inventory.main.service.siteserviceimpl' 2015-06-26 19:23:17.987 debug 13561 --- [ main] .prepostannotationsecuritymetadatasource : @org.springframework.security.access.prepost.postfilter(value=haspermission(filterobject, 'read')) found on specific method: public au.com.xxxx.xxxx.inventory.main.domain.site au.com.xxxx.xxxx.inventory.main.service.siteserviceimpl.getsite(java.lang.long) 2015-06-26 19:23:17.990 debug 13561 --- [ main] m.delegatingmethodsecuritymetadatasource : caching method [cachekey[au.com.xxxx.xxxx.inventory.main.service.siteserviceimpl; public abstract au.com.xxxx.xxxx.inventory.main.domain.site au.com.xxxx.xxxx.inventory.main.service.siteservice.getsite(java.lang.long)]] attributes [[authorize: 'permitall', filter: 'null', filtertarget: 'null'], [authorize: 'null', filter: 'haspermission(filterobject, 'read')']]
so strange other annotations ignored on service interface , 1 particular method recognized have annotation. alss strange thing per log statements above, finds @postfilter on service implementation class, defined in interface !!!!!! , have made sure there no other interface/classes of same name on classpath.
your stack trace not clear. helpful if post entire log getting. here quick fix, check whether have added @service annotation on serviceimpl calss , make sure service package should configured in . remember in spring every thing component represent @component annotation , @service , @repository sub annotations of @component.
Comments
Post a Comment