Secure Odoo API Integrations: A Guide to Connector Tokens
Stop sharing Odoo admin credentials for integrations. Discover the modern, secure approach using dedicated service users, least-privilege permissions, and revocable API keys. Our step-by-step guide shows you how to create secure connector tokens, avoid common mistakes, and protect your ERP data.
Secure Odoo API Integrations: A Guide to Connector Tokens
As Odoo's footprint expands across industries, the need to integrate it with third-party tools, monitoring services, and custom scripts has become a business necessity. However, this connectivity introduces significant security challenges. The most common and dangerous anti-pattern we see is the sharing of powerful user credentials, often the system administrator's, to power these integrations. Every shared credential is a permanent, unscoped, and irrevocable attack surface waiting to be exploited.
This practice, born out of convenience, creates a ticking time bomb within your ERP system. It bypasses fundamental security principles and leaves your most critical business data—financial records, customer information, and internal operations—exposed. , we'll dissect the risks of this outdated approach and provide a step-by-step blueprint for a modern, secure integration strategy using dedicated service users and API connector tokens.
The Hidden Dangers of Shared Admin Credentials
Using an admin user's password for an API connection might seem like a quick fix, but it dismantles your security posture from the inside. Let's explore the specific, severe risks this introduces.
- Unscoped Power and Total Access: An Odoo admin user holds the keys to the kingdom. When you share these credentials, you're not just granting access to one specific function; you're giving the integration—and anyone who compromises it—the ability to read, write, and delete every model and every record. This includes sensitive data like employee contracts in
hr.employee, financial statements inaccount.move, and your entire customer list inres.partner. - The Chain Reaction of Revocation: What happens when the employee whose admin account is being used leaves the company? Or when a security policy mandates a password change? Changing the admin password instantly breaks every single integration relying on it. This can lead to a frantic scramble to update credentials across multiple systems, causing operational downtime for monitoring, backups, and custom workflows.
- The Audit Trail Black Hole: Effective security relies on a clear audit trail. When all automated actions are performed by the 'admin' user, it becomes impossible to distinguish a legitimate system change made by a human administrator from an action performed by your monitoring tool or a potentially malicious script. This ambiguity is a nightmare for forensic analysis after a security incident and can create significant compliance issues.
- Credential Lifecycle Negligence: The password used for your monitoring tool was likely set up months or even years ago. When was it last rotated? Stale, powerful credentials that are never changed are a prime target for attackers. The "set it and forget it" mentality turns a simple integration into a persistent, high-value vulnerability.
A Modern Approach: The Principle of Least Privilege
The cornerstone of modern API security is the Principle of Least Privilege (PoLP). This principle dictates that any user, program, or process should have only the bare minimum permissions necessary to perform its function. Instead of granting god-mode access, you create a purpose-built identity with a strictly limited and auditable scope.
In the context of Odoo integrations, this is achieved through two key components:
- Dedicated Service Users: A non-human user account created for a single, specific application or service. This user has no interactive login rights and is exclusively for programmatic access.
- Scoped API Keys: A unique, revocable token generated for that service user. This key replaces the user's password for authentication, allowing for granular control and instant revocation without affecting the user account itself or any other integrations.
This model transforms your security from a fragile, all-or-nothing system to a resilient, granular, and auditable framework. Each integration is isolated, its access is strictly defined, and its lifecycle can be managed independently.
How NonaGuard's Secure Connector Tokens Work
NonaGuard is built on this modern security foundation. Our connector token system is designed to provide secure, read-only access to your Odoo instance for security and health monitoring. The process is simple and secure:
- You create a dedicated 'NonaGuard Scanner' service user in your Odoo instance.
- You assign this user a minimal set of read-only permissions, granting access only to the specific models NonaGuard needs to analyze your system's configuration and health.
- You generate a unique API key for this service user directly within Odoo (for versions 14+).
- You register this information—your instance URL, database name, and the user's API key—as a secure connector token in your NonaGuard dashboard.
This token can be revoked at any time from either Odoo or NonaGuard, instantly severing the connection without impacting any other users or integrations. NonaGuard never needs, sees, or stores any high-privilege credentials.
Step-by-Step Guide to Creating a Secure Odoo Connector
Follow these steps to establish a secure connection between your Odoo instance and NonaGuard.
1. Provision a Dedicated Service User
Never reuse an employee's account or a generic 'integration' user. Each service requires its own unique identity. You can create this user through the Odoo UI or programmatically for easier automation.
# Via Odoo shell (./odoo-bin shell -d your_database)
from odoo import api, SUPERUSER_ID
# Establish the environment
env = api.Environment(cr, SUPERUSER_ID, {})
# Define the user details
user_vals = {
'name': 'NonaGuard Scanner',
'login': '[email protected]', # Use a unique, descriptive email
'active': True,
'groups_id': [(6, 0, [
env.ref('base.group_user').id, # Assign the most basic internal user group
])],
}
# Check if user already exists to make the script idempotent
service_user = env['res.users'].search([('login', '=', user_vals['login'])])
if not service_user:
service_user = env['res.users'].create(user_vals)
print(f"Successfully created service user '{service_user.name}' with ID: {service_user.id}")
else:
print(f"Service user '{service_user.name}' already exists with ID: {service_user.id}")
2. Craft a Minimalist Permission Set
This is the most critical step. You must grant only the read permissions NonaGuard requires. This is typically done by creating a new security group, assigning the service user to it, and then defining access control lists (ACLs) for the necessary models.
NonaGuard needs to read models related to system configuration and security posture, such as:
ir.module.module: To check installed module versions against known vulnerabilities.res.users: To audit user security settings like 2FA status and group assignments.ir.cron: To check for failing or misconfigured scheduled jobs.ir.config_parameter: To inspect critical system parameters for insecure values.ir.model.access&ir.rule: To analyze the overall security permissions structure.
Not sure where to start? Run an automated Odoo security audit with NonaGuard or try the free health check to see how we analyze these models.
Here is an example of an XML data file within a custom module to grant the required access:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="group_nonaguard_scanner" model="res.groups">
<field name="name">NonaGuard Scanner Access</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="access_nonaguard_ir_module_module" model="ir.model.access">
<field name="name">NonaGuard - Read ir.module.module</field>
<field name="model_id" ref="base.model_ir_module_module"/>
<field name="group_id" ref="group_nonaguard_scanner"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
<!-- Add similar records for all other required models -->
</data>
</odoo>
3. Generate and Test the API Key (Odoo 14+)
Starting with Odoo 14, API keys are the standard for programmatic authentication. Navigate to Settings → Users & Companies → Users, select your service user, go to the API Keys tab, and generate a new key. Always give it a descriptive name like 'NonaGuard Production Connector'.
Before saving the key in NonaGuard, test it to ensure the user and permissions are configured correctly.
# Python script to test XML-RPC connection with an API key
import xmlrpc.client
# -- Configuration --
URL = "https://your-odoo-instance.com"
DB = "your_database_name"
LOGIN = "[email protected]"
API_KEY = "your-newly-generated-api-key"
# 1. Authenticate and get the UID
try:
common = xmlrpc.client.ServerProxy(f'{URL}/xmlrpc/2/common')
uid = common.authenticate(DB, LOGIN, API_KEY, {})
if uid:
print(f"✅ Authentication successful! User ID: {uid}")
else:
print("❌ Authentication failed. Check URL, DB, Login, and API Key.")
exit()
except Exception as e:
print(f"An error occurred during authentication: {e}")
exit()
# 2. Attempt to read a required model
try:
models = xmlrpc.client.ServerProxy(f'{URL}/xmlrpc/2/object')
module_count = models.execute_kw(DB, uid, API_KEY, 'ir.module.module', 'search_count',
[[('state', '=', 'installed')]])
print(f"✅ Successfully executed read operation. Found {module_count} installed modules.")
except Exception as e:
print(f"❌ Read operation failed. This likely indicates a permission issue.")
print(f" Error details: {e}")
4. Register the Connector in NonaGuard
With a working API key, the final step is simple. In your NonaGuard dashboard, navigate to the Connectors page and add a new instance. Enter the URL, database name, service user login, and the API key. NonaGuard will perform a connection test to validate access to all required models.
Common Mistakes to Avoid When Securing Odoo APIs
Setting up secure connectors is straightforward, but a few common missteps can undermine your efforts.
- Reusing Service Accounts: It's tempting to create a single 'integration' user for all your third-party services. Don't. If that single user is compromised, all connected systems are at risk. A dedicated user per service ensures that a compromise is contained to that single service.
- Over-Provisioning Permissions: When a connection fails due to a permission error, the easy fix is to grant broader access, like 'Administration / Settings'. This completely defeats the purpose of the Principle of Least Privilege. Always diagnose the specific model access error and grant only the required permission.
- Hardcoding Credentials: Never store API keys or passwords directly in your code, configuration files, or Git repositories. Use environment variables, a secure vault service (like HashiCorp Vault or AWS Secrets Manager), or your hosting provider's secret management tools.
- Forgetting Key Rotation: API keys should have a defined lifecycle. Establish a policy to rotate keys quarterly or annually. This limits the window of opportunity for an attacker if a key is ever exposed.
Advanced Security Layers for Your Odoo Connector
For enhanced security, you can supplement your connector token with network-level controls.
IP Whitelisting: Configure your reverse proxy (like Nginx or Apache) to only allow requests to Odoo's XML-RPC endpoint (/xmlrpc/2/) from NonaGuard's known IP addresses. This provides a powerful defense-in-depth layer, blocking any unauthorized connection attempts before they even reach Odoo.
Here is a sample Nginx configuration snippet:
# /etc/nginx/conf.d/odoo.conf
# Define a map of allowed IPs for NonaGuard
geo $nonaguard_ip {
default 0;
# Replace with NonaGuard's actual IP ranges
198.51.100.1/32 1;
203.0.113.0/24 1;
}
server {
listen 443 ssl;
# ... your other server config ...
location /xmlrpc/2/ {
# Check if the request is from a NonaGuard IP
if ($nonaguard_ip = 0) {
# If not, deny the request
return 403;
}
# If it is, proxy it to the Odoo backend
proxy_pass http://odoo_backend;
# ... your other proxy settings ...
}
}
Monitoring and Alerting: Regularly review Odoo's logs for access patterns related to your service user. Set up alerts for an unusual volume of requests or access attempts from unexpected IP addresses, which could indicate a compromised key.
Frequently Asked Questions
Why can't I just use my admin password? It's faster.
Using an admin password creates severe security risks, including providing total, unscoped access to all your data, breaking all integrations if the password changes, and creating an unauditable black hole for automated actions. A dedicated service user with a scoped API key is the industry standard for secure, manageable, and resilient integrations.
Does the NonaGuard connector modify any data in my Odoo instance?
No. The NonaGuard connector operates on the Principle of Least Privilege and only requires read-only permissions for a specific list of system models. It cannot write, create, or delete any data in your Odoo database. Its sole purpose is to analyze your configuration and security posture.
How often should I rotate my API keys?
Best practices suggest rotating API keys at least annually. For highly sensitive systems, a quarterly rotation policy is even better. The process should be: generate a new key, update the key in the NonaGuard connector, confirm the connection works, and then revoke the old key in Odoo.
What if my Odoo version is older than 14 and doesn't have API keys?
While Odoo 14+ is recommended for its native API key support, you can still follow the same security principles on older versions. You should still create a dedicated service user with minimal read-only permissions. For authentication, you would use the user's password instead of an API key. This still provides critical benefits like user isolation and a clear audit trail, though it lacks the easy, one-click revocation of a dedicated API key.
Related resources
Odoo Security Audit
Deep detection for permissions, CVEs, and module vulnerabilities.
Platform Features
Explore scanning, remediation, reporting, and automation capabilities.
Plans & Pricing
Compare Solo, Agency, and Partner plans.
Free External Scan
Run a no-login URL security check directly from the landing page.
Monitor Your Odoo Instances
Start monitoring your Odoo instances for risks and vulnerabilities in 60 seconds.
Start Free TrialLooking for advanced Odoo modules? Visit Hexalian Store