$ whoami
$ whoami
more frightening than centralized auth, even though it brings super interesting properties
┌───────┐ auth data ┌────────────────┐ │ user ├──────────────────▲│ token delivery │ └─────┬─┘▼──────────────────┤ service │ ▲ │ refresh token └─────────┬──────┘ │ │ + access token ▲ │ │ │ │ │ │ │ refresh token │ │ │ └───────────────────────────┘ │ │ │ └──────────────────────────────────┘ access token + refresh token
// datalog payload: data
user("01GXHB9ZFJEAWF9QN7WEDX6E1E");
// datalog payload: auth rules
check if time($time), $time < 2023-03-31T00:10:46Z;
// datalog payload: data
user("01GXHB9ZFJEAWF9QN7WEDX6E1E");
// datalog payload: auth rules
check if time($time), $time < 2023-03-31T00:10:46Z;
// context provided by the server
time(2023-03-31T00:00:00Z);
resource("file1");
operation("read");
// rules provided by the server
right("01GXHB9ZFJEAWF9QN7WEDX6E1E", "file1", "read");
allow if user($user),
resource($r),
operation($op),
right($user, $r, $op);
allow if
// block appended by the token holder: the resulting
// token can only be used locally
check if source_ip("127.0.0.1");
trusted network ┌────────────────────────────────────┐ │ │ │ services │ │ ┌───┐ │ ┌─┴┐ trusted │ │ trusted│ │ ├─────────────────────► 1 ├─────┐ │ │g │ └───┘ │ │ │a │ │ │ untrusted│t │ ┌───┐ │ │ ────────►│e │ trusted │ │ │ │ │w ├─────────────────────► 2 │◄────┘ │ │a │ └───┘ │ │y │ │ │ │ ┌───┐ │ │ │ trusted │ │ │ │ ├─────────────────────► 3 │ │ └─┬┘ └───┘ │ │ │ └────────────────────────────────────┘
incoming credentials ┌─────────────┐ │ │ │ services │ incoming │ ┌────┐ │ ─────────────┴──►│ │ │ request │ 1 ├────▼┐ └────┘ │ │ authorized ┌────┐ │ as incoming │ │ │ request │ 2 │◄────┘ └────┘
incoming credentials ┌─────────────┐ │ │ │ services │ incoming │ ┌────┐ │ ─────────────┴──►│ │ ┌─┴───┐ request │ 1 ├──┤magic│ └────┘ └─┬───┘ │ authorized as incoming ┌────┐ │ request │ │ │ (+ request-specific │ 2 │◄───┘ restrictions) └────┘
services ┌───┐ ┌──┐ │ │ │ ├─────────────────────► 1 │ │g │ ▲ └───┘ │a ├──┘inject rights access │t │ ┌───┐ ────────►│e │ │ │ token │w ├─────────────────────► 2 │ │a │ ▲ └───┘ │y ├──┘ │ │ inject rights ┌───┐ │ │ │ │ │ ├─────────────────────► 3 │ └─┬┘ ▲ └───┘ └───┘ inject rights
┌────────┐ auth data ┌────────┐ │ ├─────────────►│token │ │ user │ │delivery│ │ │◄─────────────┤service │ └─┬────┬─┘ token(s) └────────┘ │ │ │ │ │ │ ┌───────┐ │ └─────────────────►│service│ │ │ 1 │ │ └───────┘ │ │ ┌───────┐ └──────────────────────►│service│ │ 2 │ └───────┘
the auth service is called once and then services are accessed directly