quak login --server: log in to a self-hosted Ente server (closes #243)
check / check (push) Successful in 4m25s
check / check (push) Successful in 4m25s
`quak login` takes the server's API address from `--server` or `QUAK_SERVER`, refusing anything that is not an http or https URL. The client's snapshot now keeps a non-default `apiOrigin`, so the session file names the server and every later command uses it. A snapshot's `apiOrigin` wins over the one in `fromJSON`'s `apiOptions`, since the token belongs to that server. Model: opus-5-5
This commit is contained in:
1 parent
9bd7e8f099
commit
b6020aca4e
7 files changed
+241
-15
No files matched your search
@@ -229,7 +229,7 @@ below belong to quak itself, and go before or after the command's name.
|
||||
### The commands
|
||||
|
||||
```
|
||||
quak login
|
||||
quak login [--server <url>]
|
||||
quak whoami
|
||||
quak logout
|
||||
quak collections [--json]
|
||||
@@ -246,13 +246,26 @@ Every command but `login` and `logout` needs a saved session. Every command but
|
||||
`login`, `whoami` and `logout` opens the library. How each one gets current data
|
||||
from the server is described under "How a command gets current data".
|
||||
|
||||
#### `quak login`
|
||||
#### `quak login [--server <url>]`
|
||||
|
||||
Logs in to an account and saves the session. It reads the email from
|
||||
`QUAK_EMAIL` and the password from `QUAK_PASSWORD`. For each one that is not
|
||||
set, it asks on the terminal. The password shows as `*` characters while it is
|
||||
typed.
|
||||
|
||||
quak logs in to Ente's hosted service unless you name a self-hosted Ente server.
|
||||
Name it with `--server`, or with `QUAK_SERVER` when `--server` is not given.
|
||||
Give the address of the server's API, for example
|
||||
`quak login --server https://ente.example.com`. The address is an http or https
|
||||
URL. It may include a path, but no query or fragment. quak refuses any other
|
||||
address before it asks for anything. It logs
|
||||
`Invalid server address "<url>": it must be an http or https URL with no query or fragment`,
|
||||
and the exit status is 1.
|
||||
|
||||
The session file keeps the server's address. Every later command, cron runs
|
||||
included, uses that server without further setting. To change server, log in
|
||||
again.
|
||||
|
||||
When the account has a second factor, quak asks for the code. It asks
|
||||
`TOTP code: ` for a time-based code from an authenticator app. An account whose
|
||||
only second factor is a passkey cannot log in with quak. When the account has
|
||||
@@ -597,9 +610,11 @@ Linux that is `$XDG_DATA_HOME/quak/session.json`, or
|
||||
mode `0600`, in a directory it creates with mode `0700`.
|
||||
|
||||
The file holds the account's email, its user ID, the session token and the
|
||||
account's three keys, in base64 and unencrypted. Treat it as you would treat the
|
||||
password. A missing file means "not logged in". A file that cannot be read back
|
||||
is reported as corrupt, with the reason. Run `quak logout`, then `quak login`.
|
||||
account's three keys, in base64 and unencrypted. After a login to a self-hosted
|
||||
server, it also holds the server's address as `apiOrigin`. Treat it as you would
|
||||
treat the password. A missing file means "not logged in". A file that cannot be
|
||||
read back is reported as corrupt, with the reason. Run `quak logout`, then
|
||||
`quak login`.
|
||||
|
||||
A command that needs a session exits 3 when the file is missing or corrupt. It
|
||||
also exits 3 when the server no longer accepts the session, and prints
|
||||
@@ -1477,6 +1492,11 @@ write wherever it likes. `Client.fromJSON(snapshot, apiOptions?)` restores a
|
||||
working client from that snapshot without logging in again. It checks every
|
||||
field and each key's length first, and throws an error naming the bad field.
|
||||
|
||||
A client whose `apiOptions` named an `apiOrigin` puts it in its snapshot. The
|
||||
restored client then uses that server, even when the `apiOptions` given to
|
||||
`Client.fromJSON` name another. A snapshot without `apiOrigin` uses the
|
||||
`apiOrigin` of those `apiOptions`, or the default server.
|
||||
|
||||
`Client.fromJSON` works only once libsodium, the cryptography library quak uses,
|
||||
is loaded. `Client.login` loads it, and `Client.fromJSON` does not. A program
|
||||
that restores a session in a new process first runs `await sodium.ready`, with
|
||||
|
||||
Reference in new issue
Block a user