Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What does Spring Security's ACL module provide, and when would a PermissionEvaluator with hasPermission() be simpler?

The spring-security-acl module stores per-object permissions in database tables, covering object identities, permission entries and security identities (SIDs), and checks them through an AclPermissionEvaluator. It suits applications where permissions are granted per object to users or groups, like document sharing, but it adds a schema, caching and real complexity. When access can be decided from data we already have, such as ownership, a small custom PermissionEvaluator is simpler, and expressions like @PreAuthorize("hasPermission(#id, 'Invoice', 'read')") work with either.

Why this question is asked

Sooner or later every application needs rules about individual objects: this user may edit this document, that user may only read it. Spring Security offers two ways to plug such rules into hasPermission() expressions, and choosing the wrong one costs either months of complexity or a rewrite later. Interviewers ask this question to see whether we know what the ACL module really is and when it is worth it. In this answer, we will recap domain object security, look at the ACL module's tables and how a check runs, see what it costs, write a simple PermissionEvaluator, and compare the two.

1A Quick Recap: Domain Object Security

URL rules and roles answer questions about kinds of things: may a support agent open invoices? Domain object security answers questions about one specific thing: may this agent open invoice 42? Spring Security connects such questions to method security through the hasPermission() expression. Whatever we write there is handed to a PermissionEvaluator, an interface with two methods: one receives the object itself, the other receives an id and a type name.

So the expression is the same; what changes is the evaluator behind it. The ACL module provides one evaluator backed by tables of explicit grants, and we can write our own backed by our own logic.

2What the ACL Module Stores

An access control list (ACL) is a list of grants attached to one object. The ACL module keeps them in four tables, created from a schema script shipped with the module: acl_sid for security identities, acl_class for domain classes, acl_object_identity for each protected object and acl_entry for the grants themselves.

Object identities have an owner and an optional parent, and they can inherit entries from that parent, so sharing a folder can share every document in it. Permissions are bit masks such as READ and WRITE. Granting access is done in code through a MutableAclService, as below.

Java
ObjectIdentity oi = new ObjectIdentityImpl(Document.class, 42L);
MutableAcl acl = aclService.createAcl(oi); // owner: current user (anne)
acl.insertAce(acl.getEntries().size(), BasePermission.READ, new PrincipalSid("bob"), true);
aclService.updateAcl(acl);
// Later, as bob:
// @PreAuthorize("hasPermission(#id, 'com.example.Document', 'read')")
// documents.get(42) -> allowed
// documents.get(43) -> AccessDeniedException (no entry for bob)
Tables of spring-security-acl
TableOne row perExample
acl_sidsecurity identity: user or authorityprincipal bob; authority ROLE_EDITOR
acl_classdomain classcom.example.Document
acl_object_identitydomain object, with owner and parentDocument 42, owner anne, parent folder 7
acl_entrygrant on an object to a SIDDocument 42: bob READ granted
Permissions are bit masks: READ 1, WRITE 2, CREATE 4, DELETE 8, ADMINISTRATION 16.

Notice that bob gets READ on document 42 only. The grant is a row in acl_entry pointing at his SID and the document's object identity, and nothing else about bob or the document had to change.

3How an ACL Check Runs, and What It Costs

When the expression is evaluated, the AclPermissionEvaluator builds an object identity from the id and type, collects the SIDs of the current user (their principal and every granted authority), asks the AclService to load the ACL for the object and its parents, and checks whether any entry grants the permission to any of those SIDs.

Step throughhasPermission(#id, 'Document', 'read') with ACLs
  1. Build ObjectIdentityDocument, 42
  2. Collect user's SIDsPrincipalSid bob, GrantedAuthoritySid ROLE_EDITOR
  3. ACL in cache?
    YesUse cached ACLNoLoad from 4 tables, cache it
  4. Entry grants READ to a SID?checks parents too
    YesAllowNoAccessDeniedException

4 steps in order. Play them, or step through them one at a time.

The costs are real. We add four tables, a lookup strategy, an ACL cache (without one, every check is several joins), an authorization strategy for who may change ACLs, and code that creates and deletes ACL rows whenever domain objects are created or deleted, in the same transaction. Lists are the hardest part: ACLs answer is this object allowed, not which objects are allowed, so a page of 50 documents means 50 checks or a custom query against the ACL tables. For an application whose model really is explicit sharing, that cost buys exactly the right feature.

4A Custom PermissionEvaluator for Rules We Already Know

Many applications do not grant permissions per object at all. An invoice is readable by its customer and by support staff, full stop. All the information is already in the invoice row, so storing ACL entries would just duplicate it. A custom evaluator expresses the rule in plain Java.

Java
@Component
class AppPermissionEvaluator implements PermissionEvaluator {
private final InvoiceRepository invoices;
AppPermissionEvaluator(InvoiceRepository invoices) { this.invoices = invoices; }
@Override
public boolean hasPermission(Authentication auth, Object target, Object permission) {
if (target instanceof Invoice i && "read".equals(permission)) {
return i.customerId().equals(auth.getName()) || hasAuthority(auth, "ROLE_SUPPORT");
}
return false; // unknown type or permission: deny
}
@Override
public boolean hasPermission(Authentication auth, Serializable id, String type, Object permission) {
if (!"Invoice".equals(type)) return false;
return invoices.findById((Long) id).map(i -> hasPermission(auth, i, permission)).orElse(false);
}
private static boolean hasAuthority(Authentication a, String name) {
return a.getAuthorities().stream().anyMatch(g -> name.equals(g.getAuthority()));
}
}
@Bean
static MethodSecurityExpressionHandler expressionHandler(AppPermissionEvaluator evaluator) {
var handler = new DefaultMethodSecurityExpressionHandler();
handler.setPermissionEvaluator(evaluator);
return handler;
}
@PreAuthorize("hasPermission(#id, 'Invoice', 'read')")
public Invoice get(Long id) { ... } // alice reading her invoice 42 -> allowed; bob -> denied

Notice that the default is deny: an unknown type or permission returns false. The annotation is exactly the one we would use with the ACL module, so if the application later needs real sharing, we can swap the evaluator, or delegate from ours to an AclPermissionEvaluator for some types, without touching any service method. How the evaluator is registered has become simpler in recent versions; check your version, but the expression handler bean shown here works throughout 6.x.

5Choosing Between Them

The deciding question is where the permission comes from. If it can be computed from existing data, such as ownership, department, status or tenant, a PermissionEvaluator, or even a plain query filter, is simpler and faster. If it comes from explicit grants that users make to each other, such as share this document with Bob for editing, the information must be stored somewhere, and the ACL module is a ready-made, tested way to store and check it. Many applications mix both: computed rules for most objects and explicit grants only for the shareable ones.

6Follow-up questions

Is the ACL module still maintained?

It is part of Spring Security and still shipped, but it is a mature module that changes rarely, and its design predates newer approaches such as relationship-based authorization services. For a new product built around sharing, it is worth comparing it with those options too.

Why does the permission parameter accept 'read' as a string?

The AclPermissionEvaluator uses a PermissionFactory to turn names like read or numbers like 1 into Permission objects. Our custom evaluator receives whatever we write and interprets it itself, so we should define a small fixed set of permission names.

Can hasPermission check an object returned by the method?

Yes, with @PostAuthorize("hasPermission(returnObject, 'read')"), which calls the evaluator method that receives the object, avoiding a second database load.

7Conclusion

In this answer, we saw that spring-security-acl stores explicit per-object grants in tables for SIDs, classes, object identities and entries, and checks them through an AclPermissionEvaluator, which suits sharing features but brings a schema, caching, lifecycle code and awkward list queries. A custom PermissionEvaluator computes permissions from data we already have, such as ownership, with plain Java. Both serve the same hasPermission() expressions, so we can start simple and switch later.

What to say in the interviewAbout 80 seconds aloud

Open with

The ACL module gives us per-object permissions stored in the database. It has four tables: acl_sid for security identities, which are users or authorities, acl_class for domain types, acl_object_identity for each object with its owner and optional parent for inheritance, and acl_entry for grants such as bob has READ on document 42.

Then, if they want more

An AclPermissionEvaluator answers hasPermission expressions by collecting the user's SIDs, loading the object's ACL, ideally from a cache, and checking the entries. It is the right tool when permissions are granted per object to users or groups, like sharing documents or folders.

But it adds a schema, an ACL cache, code to create and delete ACL rows alongside domain objects, and it is awkward for lists, because it checks one object at a time.

If the rule can be computed from data we already have, like the invoice's customer id or the user's support role, I would write a custom PermissionEvaluator instead: plain Java, deny by default, registered on the method security expression handler.

The nice part is that the annotation, for example @PreAuthorize("hasPermission(#id, 'Invoice', 'read')"), is the same with either evaluator, so we can start with the simple one and move to ACLs or a sharing service only if the product needs explicit grants.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Security reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What does Spring Security's ACL module provide, and when would a PermissionEvaluator...": https://scrivio-interview-library.netlify.app/spring-boot/authorization/ba3d7a010f/