Custom Authentication Configuration
The Custom Authentication Configuration file allows system administrators to implement advanced security and authentication controls that are not available through the standard web interface. These settings control IP-based access restrictions, account masquerading for troubleshooting, and XML API access.
Location and Setup
The custom authentication configuration is managed through a PHP file located in your installation:
~/admin/com/custom/authentication.phpInitial Setup
-
Navigate to the custom directory:
Terminal window cd ~/admin/com/custom/ -
Copy the example file to create your configuration:
Terminal window cp authentication.example.php authentication.php -
Edit the file with your preferred text editor:
Terminal window nano authentication.php -
Set appropriate file permissions:
Terminal window chmod 640 authentication.php
Configuration Structure
The configuration file uses a PHP array structure with predefined keys:
<?php$custom = [ 'admin_allow_ip' => [], 'admin_allow_ip_enabled' => false, 'regularuser_allow_ip' => [], 'regularuser_allow_ip_enabled' => false, 'enable_masquerade' => true, 'masquerade_token_separator' => '::', 'enable_xmlapi' => false, 'xmlapi_admin_only' => true];IP Restriction for System Administrators
Restrict System Administrator login to specific IP addresses for enhanced security.
Configuration Options
admin_allow_ip
An array of IP addresses allowed to login as System Administrator.
Example:
'admin_allow_ip' => [ '127.0.0.1', // Localhost '192.168.1.100', // Static office IP '10.0.0.0/8', // Private network range gethostbyname('vpn.yourcompany.com') // Dynamic hostname],Supported formats:
- Single IP addresses:
'192.168.1.100' - CIDR notation:
'10.0.0.0/8'(if supported by your implementation) - Dynamic IPs via DNS:
gethostbyname('hostname.com')
admin_allow_ip_enabled
Boolean flag to enable/disable IP restrictions for System Administrators.
Values:
true- Enable IP restrictions (only IPs inadmin_allow_ipcan login as admin)false- Disable IP restrictions (default behavior)
Example Configuration
// Restrict admin login to office and VPN IPs only'admin_allow_ip' => [ '203.0.113.50', // Office static IP '203.0.113.51', // Backup office IP gethostbyname('vpn.example.com') // VPN gateway],'admin_allow_ip_enabled' => true,Use Cases
Scenario 1: Office-only admin access
'admin_allow_ip' => ['203.0.113.50'],'admin_allow_ip_enabled' => true,Scenario 2: Multiple offices and VPN
'admin_allow_ip' => [ '203.0.113.50', // New York office '198.51.100.25', // London office gethostbyname('vpn.company.com') // Corporate VPN],'admin_allow_ip_enabled' => true,IP Restriction for Regular Users
Similar to admin restrictions, but applies to all non-administrator user accounts.
Configuration Options
regularuser_allow_ip
An array of IP addresses allowed for regular user login.
regularuser_allow_ip_enabled
Boolean flag to enable/disable IP restrictions for regular users.
Example Configuration
// Restrict all regular users to company network only'regularuser_allow_ip' => [ '10.0.0.0/8', // Internal network gethostbyname('vpn.company.com') // VPN access],'regularuser_allow_ip_enabled' => true,Account Masquerading Debug Feature
Account masquerading allows System Administrators to login as another user for troubleshooting purposes without knowing their password.
How It Works
When enabled, a System Administrator can login using a special username format:
adminusername::targetusernameThe system will:
- Verify the admin’s credentials
- Verify the admin has System Administrator privileges (
admintype = 'a') - If valid, log them in as the target user
- All actions are performed as the target user
Configuration Options
enable_masquerade
Enable or disable the masquerading feature.
Values:
true- Enable masquerading (default)false- Disable masquerading
masquerade_token_separator
The character sequence that separates admin username from target username.
Default: ::
Custom example:
'masquerade_token_separator' => '##', // Use admin##targetuser formatExample Usage
Configuration:
'enable_masquerade' => true,'masquerade_token_separator' => '::',Login scenario:
- Admin username:
sysadmin - Admin password:
SecureP@ss123 - Target user:
john.doe
Login as target user:
- Navigate to the login page
- Enter username:
sysadmin::john.doe - Enter password:
SecureP@ss123(admin’s password, not john.doe’s) - You are now logged in as
john.doe
Security Considerations
Disabling Masquerading
For production environments where this feature is not needed:
'enable_masquerade' => false,XML API Access Control
Control whether the XML API authentication is available system-wide.
Configuration Option
enable_xmlapi
Global enable/disable switch for XML API authentication.
Values:
true- XML API authentication enabledfalse- XML API authentication disabled system-wide (default)
xmlapi_admin_only
Restricts XML API access to administrator accounts only, even when a non-admin user has a valid XML token.
Values:
true- Only admin users can access the XML API (default)false- Non-admin users with a valid XML token can also access the XML API
Example Configuration
Disable XML API completely:
'enable_xmlapi' => false,Enable XML API for admin users only (default behavior):
'enable_xmlapi' => true,'xmlapi_admin_only' => true,Enable XML API for all users with valid tokens:
'enable_xmlapi' => true,'xmlapi_admin_only' => false,Complete Configuration Examples
Maximum Security Configuration
<?php/** * High-security configuration for production environment * - Admin access restricted to office IP only * - Regular users restricted to internal network * - Masquerading disabled * - XML API disabled */$custom = [ 'admin_allow_ip' => [ '203.0.113.50', // Office static IP ], 'admin_allow_ip_enabled' => true,
'regularuser_allow_ip' => [ '10.0.0.0/8', // Internal network ], 'regularuser_allow_ip_enabled' => true,
'enable_masquerade' => false,
'masquerade_token_separator' => '::',
'enable_xmlapi' => false,
'xmlapi_admin_only' => true];Development/Staging Configuration
<?php/** * Flexible configuration for development environment * - No IP restrictions * - Masquerading enabled for testing * - XML API enabled for all users */$custom = [ 'admin_allow_ip' => [], 'admin_allow_ip_enabled' => false,
'regularuser_allow_ip' => [], 'regularuser_allow_ip_enabled' => false,
'enable_masquerade' => true,
'masquerade_token_separator' => '::',
'enable_xmlapi' => true,
'xmlapi_admin_only' => false];Remote Work Configuration
<?php/** * Configuration for distributed team with VPN * - Admin access from VPN only * - Regular users from anywhere (MFA required separately) * - Masquerading disabled * - XML API enabled for admins only */$custom = [ 'admin_allow_ip' => [ gethostbyname('vpn.company.com'), ], 'admin_allow_ip_enabled' => true,
'regularuser_allow_ip' => [], 'regularuser_allow_ip_enabled' => false,
'enable_masquerade' => false,
'masquerade_token_separator' => '::',
'enable_xmlapi' => true,
'xmlapi_admin_only' => true];Troubleshooting
Problem: Locked Out of Admin Account
Symptom: Cannot login as System Administrator
Cause: admin_allow_ip_enabled is true but your IP is not in admin_allow_ip
Solution:
- Access server via SSH or file manager
- Edit
~/admin/com/custom/authentication.php - Set
'admin_allow_ip_enabled' => false, - Or add your IP to
admin_allow_iparray - Save and try logging in again
Problem: All Users Locked Out
Symptom: No one can login (admin or regular users)
Cause: Both IP restriction features enabled with empty arrays
Solution:
- Temporarily rename the file:
Terminal window mv ~/admin/com/custom/authentication.php ~/admin/com/custom/authentication.php.disabled - Login normally
- Fix the configuration
- Rename back:
Terminal window mv ~/admin/com/custom/authentication.php.disabled ~/admin/com/custom/authentication.php
Problem: Masquerading Not Working
Symptom: Login fails when using admin::user format
Possible causes and solutions:
-
Masquerading is disabled
- Check:
'enable_masquerade' => true
- Check:
-
Wrong separator
- Check the
masquerade_token_separatorvalue - Use the correct separator (default is
::)
- Check the
-
Not a System Administrator
- Masquerading only works for users with
admintype = 'a' - Regular admins cannot masquerade
- Masquerading only works for users with
-
Target user doesn’t exist
- Verify the target username is correct and active
Problem: XML API Not Working
Symptom: XML API requests fail with authentication error
Possible causes:
-
Global XML API disabled
- Check:
'enable_xmlapi' => true
- Check:
-
Admin-only mode is enabled
- Check:
'xmlapi_admin_only' => trueblocks non-admin users even with a valid token - Set to
falseto allow non-admin users
- Check:
-
User doesn’t have XML API permission
- Enable in user account settings separately
-
IP restrictions blocking request
- Check if request IP is in allowed list
Related Settings
For additional security configurations, see:
- Security Settings - Session timeout, two-factor authentication, and login failure handling
- User Accounts - Individual user XML API and permission settings
- Configuration File Settings - Proxy headers and other advanced config.php settings
Best Practices
- Always maintain a backup before modifying authentication settings
- Test in development first before applying to production
- Document your IP addresses with comments in the file
- Use version control to track changes to authentication.php
- Review access logs regularly when using IP restrictions
- Disable masquerading in production unless actively needed
- Consider using VPN instead of static IP lists for remote access
- Audit masquerade usage if enabled in production environments
File Permissions
Ensure proper file permissions for security:
# Recommended permissions (read-write for owner, read for group, none for others)chmod 640 ~/admin/com/custom/authentication.php
# Ensure proper ownershipchown www-data:www-data ~/admin/com/custom/authentication.php