Skip to main content
Version: ERPBridge + bridgectl ยท v0.5.0-alpha.2

Authentication

Authentication protects management endpoints and the MCP transport from unauthorized access.

HTTP authenticationโ€‹

HTTP authentication is enabled when API_AUTH_TOKEN is not empty. Send the admin credential or an API token in the Authorization header:

Authorization: Bearer <token>

The admin credential has access to every authenticated route. API tokens are scoped to mcp, metrics, or logs:

RouteRequired credential
/mcp/Admin credential or mcp scope
/metricsAdmin credential or metrics scope
/api/logs/recent, /api/logs/streamAdmin credential or logs scope
Registry, direct invoke, cache, and token routesAdmin credential
/mcp/healthAlways open

When authentication is disabled, HTTP routes keep their open-mode behavior. Guarded tools still deny calls without a verified identity. stdio remains available for open tools only; it does not provide an identity for guarded tools.

Production deployment

Set API_AUTH_TOKEN before exposing the HTTP server outside a trusted network. Open mode is intended for local development and keeps management routes unauthenticated.

Outbound ERP authenticationโ€‹

When a tool executes, the connector authenticates to the upstream ERP using the spec.security block of the tool schema.

authTypeHeader sentUse case
api-keyAuthorization: <key>Simple API keys; also accepts Frappe token key:secret.
basicAuthorization: Basic <base64(key)>Basic HTTP auth.
bearerAuthorization: Bearer <key>OAuth2 / bearer tokens.

Credential resolution โ€” credentialRef names an environment variable on the server. The connector reads os.Getenv(credentialRef) and uses that value as the key. If a non-empty reference is unset, the tool call fails closed. An empty reference means that the tool sends no outbound authentication.

Tool schema โ€” outbound auth
"spec": {
"execution": {
"type": "http",
"method": "GET",
"endpoint": "https://erp.example.com/api/v1/resource/Employee"
},
"security": {
"authType": "bearer",
"credentialRef": "ERP_API_TOKEN"
}
}
Secrets stay out of the registry

Never put the secret value in the schema. Always reference it through credentialRef so it resolves from the server environment.

Data redactionโ€‹

The logger automatically masks sensitive values before they reach console output, broadcast streams, or MCP log streams:

  • Redacted keys: password, token, api_key, secret, authorization, ssn, national_id, bank_account, plus field prefixes Secret/Private and struct tags secret/pii/masq.
  • Sensitive types: APIToken, Password, AuthHeader, SecretKey, PII.
  • Regex masking: any Bearer <value> becomes Bearer [REDACTED].

API tokensโ€‹

Token-based authentication has two credential classes:

Token classSourceScopesPurpose
Admin tokenAPI_AUTH_TOKEN environment variableall (implicit)Server administration, CLI operations
API tokensapi_tokens store (created via the control plane)mcp, metrics, logsMCP clients, monitoring, log access

Key properties:

  • API token values are shown once at creation, prefixed erpbt_; only a SHA-256 hash is stored.
  • Tokens can be scoped (mcp | metrics | logs), expire, and be revoked individually.
  • When API_AUTH_TOKEN is set, protected routes return 401 for missing or invalid credentials and 403 for insufficient scope.
  • API_AUTH_ADMIN_ROLES assigns verified roles to the admin identity.

See the API token guide for lifecycle requests and CLI usage.

Role-protected toolsโ€‹

Tools opt into authorization with spec.security.allowedRoles. Roles must match [a-z][a-z0-9_-]{0,63}, be unique, and contain no more than 32 values.

  • MCP clients select a role with arguments.role. The server validates the role against the token identity and tool allow-list, then removes it before the ERP request.
  • Direct callers select a role with X-ERPBridge-Role. A role in the JSON body is rejected for guarded tools.
  • Open tools do not reserve role, so existing business payloads remain unchanged.
  • Denied calls happen before cache lookup and downstream ERP execution.

Report authentication issuesโ€‹

Open an issue at github.com/nmdra/ERPBridge/issues.