raftdb-server accounts, roles and tokens
How raftdb-server authenticates and authorises its own clients: the admin account, user lines, roles and database scopes, the shared token, session tokens and what is not built.
These accounts are for clients of the native API (binary protocol and HTTP), the Studio, the watcher, replicas and the SQL front-end's own link to the server. They are defined when the server starts and are not stored in the database.
The first-start admin account#
With no token, no user and no open, the first start creates the account admin with a random password (24 random bytes shown as 48 hexadecimal digits) in <dir>/admin.password. The file is created readable by its owner only (mode 600 on Unix; on Windows icacls removes inherited access and grants the current user, SYSTEM and Administrators, best effort and bounded to five seconds) and is read back at every later start. The server prints the file's name, never the password. The primary profile also creates a read-only account replicator with <dir>/replicator.password.
An explicit user or token setting means no account is created for you.
Account lines#
user = NAME:PASSWORD[:ROLE[@DATABASE]]Repeatable. The role is readonly, readwrite, admin (the default) or control. A password may contain :; the last part counts as a role only if it is one. @DATABASE limits the account to one database.
Passwords are never kept: at start each is turned into a random 16-byte salt and a 32-byte PBKDF2-HMAC-SHA-256 hash with 100,000 iterations (SHA-256, HMAC and PBKDF2 are implemented in the engine and checked against FIPS 180-4, RFC 4231 and PBKDF2 test vectors). Comparisons use a constant-time equality.
Login costs: a full check is about 255 ms of CPU before the engine's optimisation (about half now). A credential that passed the full check is remembered for 10 minutes as a keyed digest (a random per-process key, at most 1,024 entries; the password is not kept), so reconnecting clients skip the hash. Only successes are cached; a wrong password always pays the full check and a fixed 250 ms delay before the refusal, which slows guessing but is not a lockout. GET /v1/server shows passwordChecks, the number of full checks run.
Roles#
| Role | May |
|---|---|
readonly | Queries, GETs, listings. |
readwrite | Also write, delete, import, create indexes. |
admin | Also create, drop, rename and checkpoint databases and tables; promote a replica. |
control | Only the /v1/control interface (role commands, state, throttles). It cannot read or write rows, so a compromised application account cannot promote a node. It can still tell a node whom to replicate from and so wipe its tables and receive the node's replication credential: keep this account for the watcher only and set control-peers on managed nodes. |
Each account has one role. The roles are cumulative from readonly to admin. An account limited with @DATABASE cannot see other databases (they disappear from listings and statistics, direct access is 403 forbidden, or error code 11 FORBIDDEN on the binary protocol) and cannot create databases, which is server-wide and needs an unlimited admin. Over the binary protocol the same rules apply to the database of the connection's current table (Use is checked against its target). GET /v1/auth/whoami returns the account's grants.
The shared token#
token = SECRETEvery client must send the secret; holders are administrators on every database. It is compared in constant time. Use it for a service that cannot do a login, and keep it out of the process list by using the settings file or the environment. With a token set, no admin account is created.
Session tokens#
POST /v1/auth/login returns a session token valid for 8 hours, for Authorization: Bearer. The binary Hello accepts user NUL password, the shared token, or a session token. Session tokens and salts come from SipHash keyed with the operating system's randomness over a counter and the clock: unpredictable without the 128-bit key, which never leaves the process. The source calls this adequate on a trusted network and says a vetted CSPRNG is to be added before wider exposure.
Open servers#
open serves with no login at all and creates no admin account. Everyone who can reach the port is an administrator. The project's conformance and benchmark scripts use it on loopback. Do not use it on a machine other people can reach.
What the SQL front-end needs#
raftdb-mysql logs into the server as raftdb_user. Give that account the role the MySQL users need: admin if they create databases and tables. Do not reuse the password anywhere else.
Not built#
- Accounts stored in the database, changing a password without a restart, revoking sessions when accounts change (accounts are fixed at start; a session token stays valid for its 8 hours).
- Per-table grants and groups of accounts.
- Replication of accounts: in a cluster every node must be started with the same
userlines, or a client that logs in on one node fails on another after a failover (PLAN-NEXT section 1 describes the design; it is not built). - Account lockout and an audit log.
- TLS.