How Liferay's Permission Framework Actually Works
Liferay's permission framework is one of its most powerful features and one of its most misunderstood. From the UI it looks like a grid of checkboxes. Underneath it is a structured evaluation engine that answers one question over and over: can this user perform this action on this resource, in this scope? Every access decision in the portal reduces to that sentence. Learn the four nouns in it - user, action, resource, scope - and the framework stops being a mystery.
The core vocabulary
The framework is built from a small set of concepts that combine into every decision.
| Concept | Meaning |
|---|---|
| Resource | A thing being protected - a portlet, a model type, or a specific entry |
| Action | An operation on that resource - VIEW, UPDATE, DELETE, ADD_ENTRY |
| Role | A named bundle of permissions assigned to users |
| Scope | The level a permission applies at - Global, Site, or an individual resource |
Resources come in two flavors
Liferay distinguishes portlet resources from model resources. A portlet resource controls access to an application as a whole - can you even see this portlet. A model resource controls access to a data type or a specific record - can you edit this particular blog entry. Confusing the two is a frequent source of bugs: granting the portlet permission does nothing if the model permission on the individual entry denies the action.
Scope decides where a permission applies
A permission is never just 'granted' - it is granted at a scope. The same VIEW action can be allowed at the Global level, at a specific Site, or only on one resource instance. A role that grants UPDATE at Site scope will not help a user edit a record that lives in a different site. Scope mismatches are silent: nothing errors, the action is simply denied.
PermissionChecker checker =
PermissionThreadLocal.getPermissionChecker();
boolean canEdit = checker.hasPermission(
groupId, // scope
BlogsEntry.class.getName(), // resource type
entry.getEntryId(), // resource instance
ActionKeys.UPDATE); // action
// Returns true only if some role grants UPDATE
// on this entry, at this scope, for this user.How a decision is actually made
When the checker evaluates a permission, it does not consult a single table. It resolves the user's effective roles - including those inherited from organization, site, and team memberships - and asks whether any of them grants the action on the resource at the required scope. Certain roles like the owner role and administrator get special short-circuit treatment. The final answer is a logical OR across all the user's roles: one grant is enough.
- Resolve the user's full set of effective roles, including inherited ones.
- Check for special cases: is the user an administrator or the owner of the resource.
- For each role, check whether it grants the action on this resource at the required scope.
- If any role grants it, allow; otherwise deny.
Why bugs hide in the layers
Because the decision is an OR across many layered inputs, permission bugs are almost never in one place. This is the same layered debugging discipline described in debugging Liferay permissions: reduce the problem to one user and one resource, then check roles, then scope, then the specific resource permission, then inheritance. The bug is usually in the interaction between two layers, not inside one.
Caching and the permission checker
Permission results are cached aggressively for performance, which is why a change sometimes does not take effect immediately. When a grant looks correct but access is still denied, suspect the cache before you suspect the configuration. Clearing the relevant cache or starting a fresh session frequently resolves what looks like a configuration bug.
Conclusion
Liferay's permission framework is a disciplined evaluation engine, not a checkbox grid. It combines resources, actions, roles, and scopes into a single yes-or-no answer, and it reaches that answer by ORing across every role a user effectively holds. Once you can state a denial in terms of those four nouns and trace it through the layers, the framework becomes predictable - and predictable systems are the ones you can trust in production.