Repository navigation
Should webERP migrate to a finer-grained security model? #1039
Replies: 3 comments 4 replies
|
I'd go with the RBAC 2.0 plan. Named permissions plus a script-to-permission table fix the whack-a-mole without bringing in a policy engine. Some things that help with this kind of migration:
I work at Permit. This comparison covers where RBAC stops being enough and what attribute and relationship rules add, which might help decide how far to take it: https://www.permit.io/blog/rbac-vs-abac-and-rebac-choosing-the-right-authorization-model |
|
There is a lot more to our security system than just the security token attached to a script. Off the top of my head, you can set who can authorise purchase orders and you can set limits on the value of purchase orders they can authorise and the currency of that order (So I could authorise invoices in GBP up to say £10,000 but I couldn't authorise any orders in EUR). You can also set whether a user can release a held purchase invoice. You can setup users authorised to use each stock location. There are restrictions in the purchase tender system, as to who can create tenders and who can accept tenders etc. You can assign individual users who can use individual general accounts. You can assign individual users who can use individual bank accounts. I'm sure I have missed lots here, but there are a lot of limits that can be set on users. Tim |
|
Also cost data (users can/can't see cost related information), prices Another issue regarding security are the "hardcoded security tokens" that allow / restrict authority. We discussed this long time ago. Probably worth it avoid having "hardcoded" anything. From SecurityTokens.php: Some are "Authority levels" like #18, more than a token assigned to a script, it defines what can be done (seen or updated) inside a script. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've been trying to create a simple set of user roles for my webERP demo and it feels like a game of whack-a-mole where once I figure out the tokens needed for one role I found I've broken another.
Does anyone want a finer-grained security model?
Related discussion:
Current Security Model
The webERP current security model has several advantages:
• Simple to understand
• Easy to audit
• Easy for administrators to configure
• Fast authorization check
and could be classified as:
For a traditional PHP ERP application, this is a perfectly reasonable and historically common design. Many applications from the 2000s and early 2010s used nearly identical patterns.
However, modern SaaS platforms have tend to evolve toward claims-based or attribute-based "role + permission" models or ABAC because they support finer-grained business rules and are easier to integrate with identity providers and SSO platforms
Comparing webERP to modern RBAC systems,
• Scripts are the security boundary, not business operations.
• One script maps to one token (some scripts implement further token requirements when finer-grained control is needed).
• Limited granularity.
• Difficult to express rules such as:
• Difficult to implement tenant-, department-, or region-specific security.
Upgrading the Security Model
webERP's security model is stronger than I suspect many developers at least initially would give it credit for. The current security model is essentially a very compact RBAC implementation:
User
→ Role
→ Token
→ Script
The biggest weakness is not the role concept. It's that the permission object is a numeric token tied directly to pages/scripts rather than a named business permission.
It would be possible to upgrade the webERP security model to a modern RBAC pattern and benefit from improved flexibility and granularity, without having to perform a wholesale replacement.
Characteristics Important to Preserve
1. Role-Centric Administration
Keep:
User → Role → Permissions
Administrators understand roles. They do not want to manage hundreds of individual permissions per user.
2. Fast Runtime Authorization
Today's check is essentially:
if ($PageSecurity in $UserTokens)which is very fast.
A modern implementation can remain equally fast:
if ($PermissionName in $_SESSION['Permissions'])The lookup is still O(1) using a hash/array.
3. Role-Based Auditing
Today you can answer:
What can Purchasing Manager do?
by examining assigned tokens.
A modern model should preserve this capability.
4. Simple Configuration
This is one of webERP's strongest qualities.
Many modern IAM systems become overly complicated:
Role
+ Claim
+ Scope
+ Policy
+ Condition
+ Resource
For a typical SME ERP system this is administrative debt (complex, brittle, difficult to make changes....)
Changes
1. Replace security token numbers with explicit permissions
Instead of:
Token 3
Token 8
Token 15
introduce explicit permissions:
PO_CREATE
PO_APPROVE
SUPPLIER_EDIT
GL_POST
GL_VIEW
Then:
Role
→ Permission
rather than:
Role
→ Numeric Token
which makes the system self-documenting.
When an auditor sees:
the meaning is immediately obvious.
2. Introduce a permission layer
Evolve the model to:
and separately:
In ERD form:
Notice something important: a script can now require multiple permissions.
Example:
PO_Approve.php
requires
PO_VIEW
PO_APPROVE
which is impossible in the current model without "in-script" token checking or creating special-purpose tokens.
Migration Strategy
The clever approach is not to remove tokens immediately.
Instead:
Phase 1
Keep existing tables.
Add:
alongside:
Phase 2
Map existing tokens.
No behavior changes.
Phase 3
Convert scripts gradually.
Instead of:
support:
Both mechanisms work during transition.
Phase 4
Retire numeric tokens.
Numeric tokens are retired after every script has migrated.
Retained Strengths
Not only are the current strengths retained they are improved.
Simple to understand
Current:
Future:
Arguably simpler.
Easy to audit
Current:
requires a lookup table.
Future:
Human-readable.
Better for auditors.
Fast authorization
Current:
Future:
Same performance profile.
Easy to configure
Current:
Future:
No increased difficulty if the UI is designed well.
Additional Improvement
Permission groups can be introduced to simplify administration.
Instead of showing hundreds of permissions:
E.g. Purchasing
Group them in the administration UI.
This maintains simplicity while allowing much finer control.
Summary
It would not be in the best interests of the webERP project to attempt moving to a complex enterprise IAM model (claims-based policies, ABAC, dynamic rules, etc.). Those approaches are powerful but the complication often exceeds the needs of a traditional ERP.
Instead, an "RBAC 2.0" model is recommended:
while preserving:
In practice, this would give webERP most of the benefits of modern RBAC while retaining the operational simplicity that has been one of the project's strengths for years.
All reactions