Module licensing and access control for ERPNext SaaS platforms
Author: Zeiad Madboly
ERPNext Module Gate allows you to sell ERPNext as modular packages. Instead of giving customers access to the entire ERPNext suite, you can control which modules they can access based on their purchase or license.
- ✅ Module-based access control - Control which ERPNext modules users can access
- ✅ Automatic role management - Users automatically get the right roles for their licensed modules
- ✅ Workspace filtering - Unlicensed modules are hidden from navigation
- ✅ Custom module support - All custom modules (non-ERPNext) are accessible by default
- ✅ Secure - Even System Managers cannot bypass module restrictions
- ✅ Administrator bypass - Full access for Administrator account
- ✅ Easy integration - Works seamlessly with ERPNext SaaS registration workflows
cd /path/to/your/bench
bench get-app erpnext_module_gate
bench install-app erpnext_module_gate
bench migrateWhen users register through your SaaS platform, they can select which modules they want. The system automatically configures their site.
# Set specific modules
bench --site [site_name] execute erpnext_module_gate.erpnext_module_gate.set_modules.set_modules
# Or grant full access (no restrictions)
bench --site [site_name] execute erpnext_module_gate.erpnext_module_gate.set_all_modules.set_all ```bash
# Run automated tests
bench --site [site_name] execute erpnext_module_gate.erpnext_module_gate.test_module_enforcement.run_tests
```
- User registers and selects modules (or you configure them)
- User logs in - System automatically assigns correct roles
- User sees only licensed modules in the workspace navigation
- User can only access doctypes from licensed ERPNext modules
- Custom modules are always accessible regardless of licensing
- ✅ Can manage users and permissions within licensed modules
- ✅ Can access Role Permission Manager (but only for licensed ERPNext modules)
- ✅ Can access all custom modules (non-ERPNext) without restrictions
- ❌ Cannot access unlicensed ERPNext module doctypes
- ❌ Cannot assign unlicensed ERPNext module roles
- ❌ Cannot bypass restrictions through any method
- ✅ Full access to everything (Administrator account)
- ✅ Can modify
site_config.jsondirectly - ✅ Can grant full access by setting
licensed_modulesto["all"]or[]or["Accounting",...]
- Accounts
- Selling
- Buying
- Stock
- Manufacturing
- Projects
- CRM
- Support
- Assets
- Maintenance
- Quality Management
- Subcontracting
- Setup (always included)
bench --site [site_name] execute erpnext_module_gate.erpnext_module_gate.set_all_modules.set_all# Via bench console
bench --site [site_name] console
# Then in console:
from erpnext_module_gate.erpnext_module_gate.api import set_licensed_modules
set_licensed_modules(["Accounts", "Selling", "Stock"])from erpnext_module_gate.erpnext_module_gate.api import get_licensed_modules
print(get_licensed_modules())Check: Verify licensed_modules is set in site_config.json:
import frappe
print(frappe.conf.get("licensed_modules"))Fix: Set modules using the methods above.
Check: Verify the app is installed and hooks are loaded:
bench restart
bench --site [site_name] clear-cacheNote: Administrator should always have full access. If not, check:
from erpnext_module_gate.erpnext_module_gate.api import is_administrator
print(is_administrator("Administrator")) # Should be TrueThe app automatically integrates with ERPNext SaaS registration workflows:
- User selects modules during registration
- Modules are stored in
site_config.json - Permissions are enforced on first login
- Workspaces are automatically filtered
- Multi-layer protection - Three security layers prevent bypass attempts
- System Manager restrictions - Even System Managers cannot access unlicensed ERPNext modules
- Custom module support - All custom modules (non-ERPNext) are accessible by default
- Administrator bypass - Only Administrator account has full access
- Real-time enforcement - Restrictions are checked on every access attempt
All custom modules outside ERPNext are accessible by default, regardless of licensing configuration. This includes:
- Modules from custom apps (e.g.,
custom_app) - Modules that don't belong to the
erpnextapp - Only ERPNext modules are restricted based on
licensed_modulesconfiguration
This means you don't need to add custom modules to the licensed modules list - they work automatically!
For detailed technical documentation, see TECHNICAL.md
For implementation status and testing guides, see:
IMPLEMENTATION_STATUS.mdTESTING_GUIDE.mdSECURITY_PROTECTIONS.md
MIT