MDDB Authentication & Authorization
Complete guide to JWT authentication and RBAC (Role-Based Access Control) in MDDB.
Authentication is compliance-aware:
- Timing-safe error unification — "user disabled or not found" now returns the same
invalid tokenresponse as a bad JWT, so an attacker can no longer probe user existence via differential error messages (services/mddbd/auth_middleware.go).- Audit trail of every auth event — every login, JWT verification, API-key check, and missing/invalid/disabled attempt is recorded to a dedicated audit bucket with actor, IP, user agent, and outcome. Enable with
MDDB_AUDIT_ENABLED=trueand query via admin-onlyGET /v1/audit.security.auth_failure_burstincident event — the newAuthFailureTrackerintegrates with the auth middleware. When the configured number of failures lands from the sameactor@ipinside the sliding window (MDDB_INCIDENT_AUTH_*), MDDB fires a webhook to every subscriber on/v1/webhookswith detail{actor, ip, count, windowSec}so your SIEM / PagerDuty / Slack receives an alert without polling.See SECURITY for the compliance map and config for every related environment variable.
Table of Contents #
- Overview
- Quick Start
- Authentication Methods
- Authorization (RBAC)
- Environment Variables
- API Endpoints
- Client Configuration
- Security Best Practices
- Testing
- Troubleshooting
Overview #
MDDB supports optional authentication and authorization to secure your markdown database. Key features:
- Disabled by default - Opt-in via
MDDB_AUTH_ENABLED=true - JWT tokens - Stateless authentication with configurable expiry
- API keys - Long-lived credentials for services and CI/CD
- RBAC - Per-collection read/write/admin permissions
- BoltDB storage - Auth data stored alongside your documents
- All protocols - Works with HTTP and gRPC
Quick Start #
1. Enable Authentication #
Start MDDB with authentication enabled:
cd services/mddbd
MDDB_AUTH_ENABLED=true \
MDDB_AUTH_JWT_SECRET=$(openssl rand -hex 32) \
MDDB_AUTH_ADMIN_USERNAME=admin \
MDDB_AUTH_ADMIN_PASSWORD=changeme \
go run .
2. Login #
curl http://localhost:11023/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"changeme"}'
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresAt": 1772563099
}
3. Use Token #
TOKEN="your-token-here"
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:11023/v1/stats
Authentication Methods #
1. JWT Tokens (Username + Password) #
Best for: Interactive users, web applications
Login to receive a JWT token:
curl http://localhost:11023/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "admin",
"password": "changeme"
}'
Use the token in subsequent requests:
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:11023/v1/add \
-d '{
"collection": "docs",
"key": "readme",
"lang": "en",
"contentMd": "# Welcome"
}'
Token Properties:
- Default expiry: 24 hours (configurable)
- Algorithm: HS256
- Contains: username, admin flag, expiry
2. API Keys #
Best for: Services, CI/CD pipelines, MCP servers
The MCP listener has its own keys (
MDDB_MCP_API_KEYS,/v1/mcp/keys) , OAuth 2.1 for clients that cannot send a key, such as claude.ai connectors. See MCP. Since v2.19.9 an MCP key can be scoped to collections, to reads, or to a chat scenario (MCP).
Create an API key:
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:11023/v1/auth/api-key \
-H "Content-Type: application/json" \
-d '{
"description": "CI server",
"expiresAt": 0
}'
Response:
{
"key": "mddb_live_b9a2604ba923ea920451d139a5f366eb384434600aff7e1d",
"description": "CI server",
"expiresAt": 0,
"createdAt": 1772476811
}
⚠️ Important: The full API key is shown only once! Save it securely.
Use API key:
curl -H "X-API-Key: mddb_live_..." \
http://localhost:11023/v1/stats
Authorization: Bearer mddb_live_... works too. On the Elasticsearch-compatible
subset under /es (MDDB_ES_COMPAT=true) the key is also accepted
as Authorization: ApiKey mddb_live_..., the header Elasticsearch clients send
for api_key=...; /v1 does not read that scheme. See
ELASTICSEARCH-COMPAT. On the Qdrant-compatible point query under /qdrant (v2.19.10+,
MDDB_QDRANT_COMPAT=true) it is also accepted as api-key: mddb_live_..., the
header qdrant-client sends; see QDRANT_COMPAT.
API Key Format:
- Prefix:
mddb_live_ - Length: 48 hex characters (24 bytes of randomness)
- Storage: SHA256 hash
- Expiry: Optional (0 = never expires)
Authorization (RBAC) #
MDDB implements Role-Based Access Control with per-collection permissions.
Permission Types #
| Permission | Operations | Description |
|---|---|---|
| read | Get, Search, Export, FTS | View documents |
| write | Add, Update, Delete, Import | Modify documents |
| admin | Backup, Restore, Stats, User management | Database operations |
Granting Permissions #
Only admins can grant permissions:
curl -H "Authorization: Bearer ADMIN_TOKEN" \
http://localhost:11023/v1/auth/permissions \
-H "Content-Type: application/json" \
-d '{
"username": "alice",
"collection": "blog",
"read": true,
"write": false,
"admin": false
}'
Removing Permissions (2.19.9+) #
A grant is removed with DELETE, the user and collection as query
parameters (a body on DELETE does not reliably survive proxies):
curl -X DELETE -H "Authorization: Bearer ADMIN_TOKEN" \
"http://localhost:11023/v1/auth/permissions?username=alice&collection=blog"
# {"status":"ok"}
# a group's grant
curl -X DELETE -H "Authorization: Bearer ADMIN_TOKEN" \
"http://localhost:11023/v1/auth/group-permissions?group=editors&collection=blog"
Only that grant goes; the user's or group's other grants stay. It stops
applying on the next request, also to login tokens and API keys issued before
the removal. That holds for removing admin on "*" as well: the admin flag
a login token carries is checked against the user's grants on every request
and dropped when the grant is gone, so the token keeps working with whatever
grants remain. (A flag is only ever taken away this way; a global admin grant
given after login needs a new login.)
| Status | When |
|---|---|
200 |
Removed |
400 |
username / group or collection missing |
403 |
The caller is not a global admin |
404 |
No such grant — permission not found (also for an unknown user or group) |
409 |
cannot remove your own global admin: the caller tried to remove their own admin on "*", which would lock them out. Another admin can remove it |
Before 2.19.9 there was no delete: a grant could only be overwritten with
read, write and admin all false, and the empty row stayed in the list. Such
rows can now be removed too. GraphQL has the same operations as
deletePermission(username, collection) and
deleteGroupPermission(groupName, collection), and the panel's permission
modals have a remove button on every row.
Wildcard Collection #
Use "*" to grant database-wide permissions:
{
"username": "bob",
"collection": "*",
"read": true,
"write": true,
"admin": false
}
Collection admin vs global admin #
"admin": true on one collection lets the user manage that collection only.
Only "admin": true on "*" makes a global admin: the admin flag in
login and API-key tokens, which passes every permission check, manages
users and permissions, and reaches admin-only endpoints.
Permission Lookup Order #
- Check if user is a global admin (admin on
"*"; bypasses all checks) - Check collection-specific permission
- Check wildcard (
"*") permission - Check the user's groups, by name: the group's grant on the collection, then its grant on
"*" - Deny by default
A tenant user is first limited to the tenant's namespace. To see which rule
lets each user read a chat scenario's collections, an admin on "*" calls
GET /v1/chat/scenarios/{name}/access (2.19.10); the panel shows it in the
scenario's Access card. See API.
Where permissions are enforced #
Every entry point of every surface — each REST route, gRPC method, MCP tool and resource, and GraphQL root field — has one rule in a table, and a gate applies that rule before the entry point runs.
The tables live next to the gates:
| Surface | Table | Gate |
|---|---|---|
| REST (API and MCP listeners) | httpAccessRules in access_rules_http.go |
every route is registered through the gate |
| gRPC | grpcAccessRules in access_rules_grpc.go |
unary and stream interceptors, after authentication |
| MCP | mcpToolAccessRules in access_rules_mcp.go |
every tools/call and resources/read, after alias resolution |
| GraphQL | graphqlAccessRules in access_rules_graphql.go |
a field middleware on Query and Mutation fields |
A rule is one of:
| Class | Needs | Examples |
|---|---|---|
| public | nothing | /health, /v1/auth/login, /metrics with MDDB_METRICS_PUBLIC=true |
| authenticated | any valid credential; touches no collection data | /v1/system/info, /v1/fts-languages, /v1/geo-encode, /v1/auth/me |
| admin | a global administrator | backup, restore, audit, encryption, automation, embedding configs, corpus build/install, user management, pprof, /v1/admin/diagnose |
| collection | read, write (or admin) on every collection the request names | /v1/fts, /v1/add-batch, /v1/ingest, /v1/schema/*, /v1/geo-*, /v1/synonyms (GET reads, POST/DELETE write) |
| handler | the entry point checks, because only it knows the collection | a job, alias or curation rule looked up by id, a multipart upload, the /es index or /qdrant collection in the path, the event stream (filtered per event), replication (its own secret, mTLS or an admin) |
How the collection is found: the query string (collection, collections)
and a JSON body (collection, sourceCollection, collections,
targetCollections) on REST; the same fields of the request message (and of
the messages it holds) on gRPC; the tool's arguments on MCP; the field's
arguments and input objects on GraphQL. All of them are checked, after alias
resolution, so a cross-collection search needs read on its source and on every
target, and a role:<role> target needs read on each collection it expands to.
A request that names no collection is about all of them and needs the
permission on "*". A tenant user may make such a request only where the
answer is filtered to its tenant (/v1/stats, /v1/vector-stats,
/v1/storage, /v1/collection-configs, /v1/corpus, gRPC ListSchemas and
ListCollectionConfigs); everywhere else it must name its collection.
The memory store (/v1/memory/*, memory_* tools) keeps three shared
collections — memory_sessions, memory_messages, memory_summaries — and
needs the permission on all three.
An entry point missing from its table is refused while auth is on, and the
completeness tests (TestEvery*IsClassified) fail, so a new route, RPC, tool
or field cannot ship without a rule. With MDDB_AUTH_ENABLED=false the gates
do nothing.
MCP calls authenticated by an MCP API key (MDDB_MCP_API_KEY_ENABLED=true)
or arriving over stdio carry no user. Over stdio and on a key without a scope
they are limited by the key's toolsets only, as before. Since v2.19.9 a key can
carry a scope — collections (aliases and role: targets resolved as RBAC
resolves them), readOnly, or a chat scenario whose allowedCollections
it reaches, read-only — and every tools/call and resources/read on it is
checked against that scope, also with main auth off: a collection outside it,
a call naming no collection, a write on a read-only key, and the
every-collection, administration and handler tools are refused with
tool "…": forbidden. Since v2.19.11 a key may also name
readOnlyCollections among its collections, which it reads but cannot write,
and a key limited to collections or a scenario uses the memory tools inside
its own memory namespace (other keys' and older sessions answer session not found); a key that is only read-only is still refused them. An OAuth token
minted from the key has its scope. See
MCP.md — Scoped keys.
With main auth on and MCP keys off, the MCP listener requires the main
credentials and every tool call is gated by RBAC.
Example Scenarios #
Scenario 1: Read-only user for analytics
# Create user
curl -H "Authorization: Bearer $ADMIN_TOKEN" \
http://localhost:11023/v1/auth/register \
-d '{"username":"analyst","password":"view123"}'
# Grant read-only to all collections
curl -H "Authorization: Bearer $ADMIN_TOKEN" \
http://localhost:11023/v1/auth/permissions \
-d '{
"username": "analyst",
"collection": "*",
"read": true,
"write": false,
"admin": false
}'
Scenario 2: Collection-specific editor
# Create user
curl -H "Authorization: Bearer $ADMIN_TOKEN" \
http://localhost:11023/v1/auth/register \
-d '{"username":"editor","password":"edit123"}'
# Grant read/write to "articles" collection only
curl -H "Authorization: Bearer $ADMIN_TOKEN" \
http://localhost:11023/v1/auth/permissions \
-d '{
"username": "editor",
"collection": "articles",
"read": true,
"write": true,
"admin": false
}'
Environment Variables #
| Variable | Default | Required | Description |
|---|---|---|---|
MDDB_AUTH_ENABLED |
false |
No | Enable authentication |
MDDB_AUTH_JWT_SECRET |
- | Yes (if auth enabled) | Secret for JWT signing (use strong random value) |
MDDB_AUTH_JWT_EXPIRY |
24h |
No | JWT token expiration (e.g., 1h, 7d) |
MDDB_AUTH_ADMIN_USERNAME |
admin |
No | Bootstrap admin username |
MDDB_AUTH_ADMIN_PASSWORD |
- | Yes (if auth enabled) | Bootstrap admin password |
Example Configuration #
Development:
export MDDB_AUTH_ENABLED=true
export MDDB_AUTH_JWT_SECRET=$(openssl rand -hex 32)
export MDDB_AUTH_ADMIN_USERNAME=admin
export MDDB_AUTH_ADMIN_PASSWORD=dev123
Production (Docker):
docker run -d \
-e MDDB_AUTH_ENABLED=true \
-e MDDB_AUTH_JWT_SECRET=your-secret-key-here \
-e MDDB_AUTH_ADMIN_USERNAME=admin \
-e MDDB_AUTH_ADMIN_PASSWORD=secure-password \
-v /data:/data \
mddb:latest
API Endpoints #
Authentication Endpoints #
POST /v1/auth/login
Login with username and password.
Request:
{
"username": "admin",
"password": "changeme"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresAt": 1772563099
}
POST /v1/auth/register
Create new user (admin only).
Request:
{
"username": "alice",
"password": "secret123"
}
Response:
{
"username": "alice",
"createdAt": 1772476836
}
POST /v1/auth/api-key
Generate API key (authenticated users).
Request:
{
"description": "CI server",
"expiresAt": 0
}
Response:
{
"key": "mddb_live_b9a2604ba923ea920451d139a5f366eb...",
"description": "CI server",
"expiresAt": 0,
"createdAt": 1772476811
}
What a key may do. A key has no permissions of its own: it acts as the
user who created it, with exactly that user's permissions at the time of each
request (direct and through groups, and the user's tenant). It cannot be
narrowed to read-only or to chosen collections. The request takes only
description and expiresAt; any other field (readOnly, collections, …)
is ignored without an error. Changing the user's permissions changes what
every key of that user may do, from the next request on.
For a key that only reads some collections, create a user that has read on
those collections and nothing else, and create the key as that user:
# as an admin
curl -X POST http://localhost:11023/v1/auth/register -H "Authorization: Bearer $ADMIN_TOKEN" \
-d '{"username":"reader","password":"<password>"}'
curl -X POST http://localhost:11023/v1/auth/permissions -H "Authorization: Bearer $ADMIN_TOKEN" \
-d '{"username":"reader","collection":"docs","read":true,"write":false}'
# as reader
curl -X POST http://localhost:11023/v1/auth/api-key -H "Authorization: Bearer $READER_TOKEN" \
-d '{"description":"read-only, docs"}'
Status codes on collection endpoints. A request without credentials gets
401. A request for a collection the caller may not use gets
403 {"error":"forbidden"}, whether or not the collection exists: permission
is checked before the collection is looked up, so 403 does not tell a caller
that a collection is there. This holds for every endpoint that names a
collection (/v1/fts, /v1/vector-search, /v1/symbol, /v1/add, …).
GET /v1/auth/me
Get current user information.
Response:
{
"username": "admin",
"admin": true,
"createdAt": 1772476700
}
Authorization Endpoints (Admin Only) #
POST /v1/auth/permissions
Set user permissions.
Request:
{
"username": "alice",
"collection": "blog",
"read": true,
"write": false,
"admin": false
}
GET /v1/auth/permissions?username=alice
Get user permissions.
Response:
[
{
"username": "alice",
"collection": "blog",
"read": true,
"write": false,
"admin": false
}
]
DELETE /v1/auth/permissions?username=alice&collection=blog
Remove one user permission (2.19.9+). 200 {"status":"ok"}; 400 without
both parameters, 404 when there is no such grant, 409 when an admin
removes their own admin on "*". The group counterpart is
DELETE /v1/auth/group-permissions?group=editors&collection=blog. See
Removing Permissions.
DELETE /v1/auth/users/:username
Delete user (admin only).
Removes the account and everything that grants it access — the record, its API keys, its per-collection permissions, and its membership of any group. The username is free immediately, so rotating a tenant's credentials by deleting and registering the same name works.
Response:
{
"status": "deleted"
}
Group membership and permissions are removed rather than carried over deliberately. Had the record been reused on re-registration instead, a name that looked free would have handed whoever claimed it the privileges of whoever held it before.
The audit log is untouched: that is where the record of who existed, and who removed them, belongs.
Public Endpoints (No Authentication Required) #
GET /healthGET /v1/healthPOST /v1/auth/loginGET /metrics— only withMDDB_METRICS_PUBLIC=true(SEC-009)
Client Configuration #
CLI (mddb-cli) #
Using JWT Token
# Login
mddb-cli login admin changeme
# Use token
mddb-cli --token YOUR_TOKEN stats
mddb-cli --token YOUR_TOKEN add docs readme en -f README.md
Using API Key
mddb-cli --api-key mddb_live_... stats
MCP Server #
The MCP server is built into mddbd; there is no separate process to give a
key to. With MDDB_AUTH_ENABLED=true an MCP client sends the same credentials
as a REST client, in the X-API-Key header or as Authorization: Bearer:
{
"mcpServers": {
"mddb": {
"transport": "streamable-http",
"url": "http://localhost:9000/mcp",
"headers": { "X-API-Key": "mddb_live_your-api-key-here" }
}
}
}
MCP-only keys (MDDB_MCP_API_KEY_ENABLED, /v1/mcp/keys) are described in
MCP.
Panel (React UI) #
The Panel automatically detects if authentication is enabled:
- On first load, attempts to access
/v1/stats - If
401 Unauthorized, shows login form - Stores JWT token in
localStorage - Includes
Authorization: Bearer TOKENin all requests - Logout button clears token and reloads page
No configuration needed!
Security Best Practices #
1. Use Strong JWT Secret #
Generate a cryptographically secure secret:
openssl rand -hex 32
Never use a weak or default secret in production!
2. Change Default Admin Password #
Immediately after first deployment:
# Login as admin
TOKEN=$(curl -s http://localhost:11023/v1/auth/login \
-d '{"username":"admin","password":"changeme"}' | jq -r .token)
# Create new admin user
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:11023/v1/auth/register \
-d '{"username":"newadmin","password":"strong-password-here"}'
# Grant admin permissions
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:11023/v1/auth/permissions \
-d '{
"username": "newadmin",
"collection": "*",
"read": true,
"write": true,
"admin": true
}'
# Delete default admin
curl -X DELETE -H "Authorization: Bearer $TOKEN" \
http://localhost:11023/v1/auth/users/admin
3. Principle of Least Privilege #
Grant minimum permissions needed:
- Read-only for analytics/reporting
- Collection-specific for editors
- Admin only for trusted operators
4. Rotate API Keys Periodically #
# Create new key with expiry
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:11023/v1/auth/api-key \
-d '{
"description": "Q1 2026 CI key",
"expiresAt": 1735689600
}'
5. Use HTTPS in Production #
Never send credentials over unencrypted HTTP in production. Use a reverse proxy like nginx or Caddy:
server {
listen 443 ssl;
server_name mddb.example.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://localhost:11023;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
6. Monitor Authentication Logs #
Watch for suspicious activity:
# In production, pipe to log aggregation service
tail -f /var/log/mddb.log | grep "authentication failed"
7. Secure Environment Variables #
In production:
- Use Docker secrets or Kubernetes secrets
- Never commit
.envfiles with real credentials - Rotate secrets regularly
Testing #
Automated Tests #
Run the comprehensive test suite:
# Test authentication, RBAC, and CLI
./test-auth.sh
# Test MCP service integration
./test-mcp.sh
# Test Panel (manual browser testing)
./test-panel.sh
Manual Testing #
1. Test Login Flow
# Should fail (401)
curl http://localhost:11023/v1/stats
# Login
TOKEN=$(curl -s http://localhost:11023/v1/auth/login \
-d '{"username":"admin","password":"changeme"}' | jq -r .token)
# Should succeed (200)
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:11023/v1/stats
2. Test RBAC
# Create limited user
curl -H "Authorization: Bearer $ADMIN_TOKEN" \
http://localhost:11023/v1/auth/register \
-d '{"username":"readonly","password":"view123"}'
# Grant read-only
curl -H "Authorization: Bearer $ADMIN_TOKEN" \
http://localhost:11023/v1/auth/permissions \
-d '{
"username": "readonly",
"collection": "docs",
"read": true,
"write": false
}'
# Login as readonly user
RO_TOKEN=$(curl -s http://localhost:11023/v1/auth/login \
-d '{"username":"readonly","password":"view123"}' | jq -r .token)
# Should succeed
curl -H "Authorization: Bearer $RO_TOKEN" \
http://localhost:11023/v1/search \
-d '{"collection":"docs","limit":10}'
# Should fail (403)
curl -H "Authorization: Bearer $RO_TOKEN" \
http://localhost:11023/v1/add \
-d '{"collection":"docs","key":"test","lang":"en","contentMd":"# Test"}'
Troubleshooting #
Problem: "missing authentication" error #
Cause: No token provided or public endpoint misconfigured.
Solution:
# Check if you're including the Authorization header
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:11023/v1/stats
Problem: "invalid token" error #
Cause: Token expired or JWT secret mismatch.
Solution:
- Check token expiry:
echo $TOKEN | base64 -d | jq .exp - Login again to get fresh token
- Verify
MDDB_AUTH_JWT_SECREThasn't changed
Problem: "forbidden" error (403) #
Cause: User lacks permissions for the operation.
Solution:
# Check user permissions
curl -H "Authorization: Bearer $ADMIN_TOKEN" \
"http://localhost:11023/v1/auth/permissions?username=alice"
# Grant required permissions
curl -H "Authorization: Bearer $ADMIN_TOKEN" \
http://localhost:11023/v1/auth/permissions \
-d '{
"username": "alice",
"collection": "docs",
"read": true,
"write": true
}'
Problem: Can't login as admin #
Cause: Admin user not created or wrong password.
Solution:
-
Check environment variables:
echo $MDDB_AUTH_ADMIN_USERNAME echo $MDDB_AUTH_ADMIN_PASSWORD -
Check server logs for bootstrap admin creation:
tail -f /var/log/mddb.log | grep "bootstrap admin" -
If needed, recreate database:
rm mddb.db # Restart server to recreate bootstrap admin
Problem: MCP client can't authenticate #
Cause: the MCP client sends no key, or a key the server does not accept.
Solution: add the key to the client's MCP configuration as a header,
"headers": {"X-API-Key": "mddb_live_your-key-here"} (or
Authorization: Bearer …); see MCP Server. With
MDDB_MCP_API_KEY_ENABLED=true, use an MCP key from /v1/mcp/keys instead.
Storage Details #
BoltDB Buckets #
Authentication data is stored in three BoltDB buckets:
-
auth_users
- Key:
user|{username} - Value: JSON with username, passwordHash (bcrypt), createdAt, disabled
- Key:
-
auth_apikeys
- Key:
apikey|{keyHash} - Value: JSON with keyHash (SHA256), username, createdAt, expiresAt, description
- Key:
-
auth_permissions
- Key:
perm|{username}|{collection} - Value: JSON with collection, read, write, admin flags
- Key:
Password Hashing #
- Algorithm: bcrypt
- Cost factor: 12
- Salt: Automatically generated per password
API Key Generation #
- Random bytes: 24 (crypto/rand)
- Encoding: Hex (48 characters)
- Prefix:
mddb_live_ - Storage: SHA256 hash (for constant-time comparison)
Migration Guide #
From No Auth to Auth Enabled #
-
Plan migration window (brief downtime required)
-
Backup database:
cp mddb.db mddb.db.backup -
Enable auth:
export MDDB_AUTH_ENABLED=true export MDDB_AUTH_JWT_SECRET=$(openssl rand -hex 32) export MDDB_AUTH_ADMIN_USERNAME=admin export MDDB_AUTH_ADMIN_PASSWORD=changeme -
Restart MDDB
-
Create users and API keys for all services
-
Update all clients (CLI, MCP, Panel, custom apps)
-
Test thoroughly before promoting to production
Rolling Back #
If you need to disable auth:
export MDDB_AUTH_ENABLED=false
# Restart server
Auth data (users, keys, permissions) remains in database but is not enforced.
See Also #
- Authentication Quick Start - Five-minute setup for the first admin user and JWT
- Implementation Summary - What the JWT/RBAC work changed across the HTTP, gRPC, GraphQL and MCP surfaces
- Security Model - ISO 27001 / SOC 2 control map and threat model
Support #
For issues or questions:
- GitHub Issues: https://github.com/tradik/mddb/issues
- Documentation: https://mddb.tradik.com/docs/readme/
- Security reports: security@tradik.com
Last Updated: March 2, 2026