Native API

Authentication

The shared token, password accounts, session tokens, roles and the clear-text limitation, on the binary and HTTP doors.

Three modes exist, chosen when the server starts.

ModeStarted withCredential
open--opennone; every caller is an administrator
shared token--token SECRETthe token
accounts--user NAME:PASSWORD[:ROLE[@DATABASE]] (repeatable)user and password, or a session token

raftdb-server started with no arguments listens on loopback only, and when no --token and no --user is given it creates the account admin with a random password in <dir>/admin.password (written once, read at every start).

HTTP#

GET /v1/auth/info is public and tells a client what to ask for. Test users_log_in_with_a_password_over_http_and_the_binary_protocol:

GET /v1/auth/info
-> {"required":true,"passwordLogin":true,"token":false}

GET /v1/server                          -> 401   (no credential)
GET /v1/databases  authorization: Bearer guess  -> 401

POST /v1/auth/login {"user":"asha","password":"wrong"}   -> 401
POST /v1/auth/login {"user":"asha"}                      -> 400
GET  /v1/auth/login                                      -> 405

POST /v1/auth/login {"user":"asha","password":"correct horse"}
-> 200 {"token":"<64 characters>","user":"asha","expiresInSeconds":28800}

Send the token on every later call as Authorization: Bearer <token>. A second login gives a separate session. POST /v1/auth/logout ends the session (200); the token then gets 401. GET /v1/auth/whoami returns {user, open, grants:[{role, database|null}]}. With a shared --token, send that token as the bearer on every /v1 request. Static Studio files are served without a token.

A failed login is answered after 250 ms. Sessions live 8 hours, in server memory.

Binary protocol#

The credential goes in Hello: the shared token as raw bytes, user NUL password, or a session token from the HTTP login. A wrong credential gets error AUTH (code 7) and the connection is closed. From the same test:

Rust
let mut c = Client::connect_user(srv.addr(), "asha", "correct horse")?;   // ok
Client::connect_user(srv.addr(), "asha", "wrong")                         // Err: code AUTH
Client::connect(srv.addr(), b"")                                           // Err on a server with accounts
Client::connect(srv.addr(), token2.as_bytes())?.ping()?;                   // session token as credential

Roles#

ROLE is readonly, readwrite or admin (default admin); each includes the ones before.

RoleMay
readonlyqueries, GETs, listings
readwritealso write, delete, import, create indexes
adminalso create, drop, rename and checkpoint tables

@DATABASE limits an account to one database: other databases vanish from /v1/databases and /v1/stats, direct access is 403 forbidden, and the account cannot create databases. The shared token and an open server are administrators everywhere. On the binary protocol the same rules apply to the connection's current table (Use is checked against its target) and a refusal is code 11 FORBIDDEN. A control role exists for the account of a watcher that manages a node; it can do nothing with data.

How passwords are kept#

Passwords are stored only as salted PBKDF2-HMAC-SHA-256 hashes (100,000 iterations), checked against FIPS 180-4, RFC 4231 and PBKDF2 test vectors. A credential that passed the full check is remembered for 10 minutes as a keyed digest (at most 1,024 entries), so reconnecting clients skip the hash; failures are never cached. See Security.

Limits#

  • No TLS. The token, passwords and session tokens cross the network in clear text. Use loopback or a trusted network. Session tokens come from SipHash keyed with the operating system's randomness; the documents say a vetted CSPRNG should replace it before wider exposure.
  • Accounts are fixed at server start. Not done: groups, per-table grants, revoking sessions when accounts change, password change.
  • Accounts and roles are not replicated; give each node its own --user list.

See also#

HTTP API, Connections, errors and versions, Security