Skip to content

Users and API keys

The users file (--users) holds local users, service API keys and role mappings for SSO identities. It reloads on SIGHUP.

Authorization header Method Roles come from
Basic base64(user:password) local user users[].roles
Bearer curral_... API key api_keys[].roles
Bearer curral_... + X-Curral-Execution-Context delegating key identities, for the subject it names
Bearer <JWT> OIDC token the token, see OIDC

Over Flight SQL, the same three methods go in the gRPC authorization header. A password login (the Flight handshake) returns a 12-hour session token for the calls that follow, recorded as basic; a restart, a password change or the user’s removal voids it, and it is refused over HTTP. In JDBC clients such as DataGrip and DBeaver, an API key goes in the token driver property.

Generate a bcrypt hash; the file never stores the password:

Terminal window
curral hash-password
# or: docker run --rm -it lucasapassos/curral hash-password
users:
- name: analyst
password_hash: "$2a$10$..."
roles: [analyst]

Verified passwords are cached for --auth-cache-ttl (default 5 minutes). A reload drops the cache, so removed users lose access immediately, Flight SQL sessions included.

For jobs and services. The key is printed once, together with the entry for the users file, which stores only its SHA-256:

Terminal window
curral gen-api-key etl-job etl
api_keys:
- name: etl-job
key_sha256: "49e4c3b9..."
roles: [etl]
expires: 2027-12-31 # optional

Clients send it as Authorization: Bearer curral_....

A key with delegation: true belongs to a trusted service that queries on behalf of its own users, naming each one in X-Curral-Execution-Context. Its own roles are never used: the effective identity gets the roles identities maps to its subject, and SQL requests are read-only. Optional attributes describe the service to the policy:

api_keys:
- name: portal
key_sha256: "..."
roles: []
delegation: true
attributes: { tenant: tenant-a }

In v0.8.0, docs_write: true also permits the key to request semantic document writes as an effective identity, subject to docs_allow. It is invalid without delegation: true. See Execution delegation.

curral does not define what a role means. Roles are strings passed to your policy, which decides what each one may do.

The client always gets a bare 401. The reason goes to the operational log, the audit log records auth_method (basic, api_key, jwt), and curral_auth_failures_total{method} counts failures. Repeated failures trigger a lockout.

A delegating key whose identity is missing or refused gets 403, and the audit log records a delegation_denied event.