I added bounty to your question because I'm also looking for a more authoritative answer.
Here's a solution that works, but there could be a better approach & cache settings could be tuned specifically for acl.
The JdbcMutableAclService
accepts any AclCache
implementation, not just EhCacheBasedAclCache
. Immediately available implementation is SpringCacheBasedAclCache
. You could also implement your own.
Enable ehcache3 in your project with Spring Cache as abstraction. In Spring Boot this is as simple as using @EnableCaching
(not @EnableCache
) annotation. Then add @Autowired CacheManager cacheManager
in your bean configuration class.
Update your ehcache3.xml with entry for aclCache
note - key is Serializable
because Spring acl inserts cache entries keyed on both Long and ObjectIdentity :)
<cache alias="aclCache">
<key-type>java.io.Serializable</key-type>
<value-type>org.springframework.security.acls.model.MutableAcl</value-type>
<expiry>
<ttl unit="seconds">3600</ttl>
</expiry>
<resources>
<heap unit="entries">2000</heap>
<offheap unit="MB">10</offheap>
</resources>
</cache>
- Replace your
EhCacheBasedAclCache
bean with SpringCacheBasedAclCache
like so:
@Bean
public AclCache aclCache() {
return new SpringCacheBasedAclCache(
cacheManager.getCache("aclCache"),
permissionGrantingStrategy(),
aclAuthorizationStrategy());
}
- Use
aclCache()
in JdbcMutableAclService
constructor