feat(auth): add operator account CLI
- Add local and container-ready user management and token commands. - Document setup and verify commands against an isolated database.
This commit is contained in:
1 parent
fe19fb9d56
commit
768a799db0
6 files changed
+570
No files matched your search
@@ -103,6 +103,33 @@ The SQLite schema is managed by TypeORM migrations in `server/src/database/migra
|
||||
|
||||
The scripts run from `server/`, so `DB_PATH` (default `data/liqa.db`) is relative to it, and they read `server/.env` if present, like the server does.
|
||||
|
||||
## Operator account commands
|
||||
|
||||
Authentication is opt-in. To manage accounts or issue tokens, set `AUTH_ENABLED=true` and `AUTH_JWT_SECRET` in the same environment used by the server. Apply database migrations before using the commands. Passwords are entered interactively without terminal echo; they are never accepted as command-line arguments.
|
||||
|
||||
Build the server and apply migrations locally, then run commands from the server workspace:
|
||||
|
||||
```bash
|
||||
npm -w server run build
|
||||
npm -w server run migration:run
|
||||
npm -w server run cli -- user:create
|
||||
npm -w server run cli -- user:get alice
|
||||
npm -w server run cli -- user:token alice # uses AUTH_JWT_EXPIRES_IN (default 24h)
|
||||
npm -w server run cli -- user:token alice 30m # optional lifetime
|
||||
npm -w server run cli -- user:delete alice
|
||||
```
|
||||
|
||||
The container image does not include npm or npx. Run the built CLI with Node inside the running service; it uses that container's configured `DB_PATH` and exits without starting the web server or schedulers:
|
||||
|
||||
```bash
|
||||
docker compose exec liqa node dist/cli.js user:create
|
||||
docker compose exec liqa node dist/cli.js user:get alice
|
||||
docker compose exec liqa node dist/cli.js user:token alice 30m
|
||||
docker compose exec liqa node dist/cli.js user:delete alice
|
||||
```
|
||||
|
||||
`user:create` asks for a username and two matching passwords. The other commands require an existing username. Lookup output contains only the account id, username, and timestamps. Token output is a bearer credential: handle it as a secret and do not paste it into logs or shared history. User deletion removes the account, so the server rejects that user's previously issued tokens on their next authentication.
|
||||
|
||||
**Changing the schema** (adding or changing an entity):
|
||||
|
||||
1. Change the entity and build (`npm -w server run build`).
|
||||
|
||||
Reference in new issue
Block a user