mfa and api wiring

This commit is contained in:
Joey Kimsey
2026-09-12 15:11:21 -04:00
parent 17d83f7209
commit 58ca586d94
11 changed files with 2065 additions and 134 deletions

View File

@ -6,7 +6,7 @@ This replaces the old `TempusToolkit` Electron stub. The keepers were the login
## Run it
From this folder (Windows source checkout is fine <EFBFBD> Capsule is Node, not PHP):
From this folder (Windows source checkout is fine ? Capsule is Node, not PHP):
```bash
npm install
@ -17,15 +17,22 @@ npm run dev
## How auth works
All HTTP runs in the **main process**. The renderer never sees the token and never talks to the site directly, so TTP<EFBFBD>s same-origin CORS policy does not apply.
All HTTP runs in the **main process**. The renderer never sees the token and never talks to the site directly, so TTP?s same-origin CORS policy does not apply.
| Action | Endpoint | Notes |
|--------|----------|-------|
| Password sign-in | `POST /api/login` | `username` + `password`, `application/x-www-form-urlencoded`. Same limiter as browser login. No CSRF, no Turnstile. |
| Confirm identity | `GET /api/users/find/{username}` | Bearer token. Returns a user id only. |
| Existing token | Admin ? Tokens | Personal or app token. Username is optional and only used for that find call. |
| Password sign-in | `POST /api/login` | `username` + `password`, `application/x-www-form-urlencoded`. Same limiter as browser login. No CSRF, no Turnstile. MFA accounts return `{ mfa }` instead of a token. |
| MFA code / method | `POST /api/login/mfa/{loginCode}` | `auth_code` or `mfaMethodSelect`. `loginCode` stays in the main process. |
| MFA reset | `POST /api/login/mfa/{loginCode}/reset` | Clears the chosen method so the picker shows again. |
| Confirm identity | `GET /api/profile` | Bearer user token. Also used to hydrate username after login. `GET /api/users/find/{username}` remains available. |
| Workspace | `GET /api/notifications`, `GET /api/messages` | First page after connect. Plugin-off responses show as unavailable. |
| Search | `GET /api/search` | Header search. `q`, `resource`, `page`. |
| Profile save | `POST /api/profile/update` | Name, avatar, prefs. |
| Mail / notices | `POST /api/messages/?`, `POST /api/notifications/?` | View, reply, create, read, delete. |
| Contact / bugs | `POST /api/contact`, `POST /api/bugreport` | Dashboard forms when those plugins are enabled. |
| Existing token | Admin ? Tokens | Personal or app token. A user token hydrates the workspace; an app token can connect but cannot call the user API. |
The token is stored under Electron `userData` (`session.json`). `safeStorage` encrypts it when the OS keychain is available.
The token is stored under Electron `userData` (`session.json`). `safeStorage` encrypts it when the OS keychain is available. MFA `loginCode` is not stored.
App-facing pairing notes live with the PHP app: `repos/ttp/docs/capsule.md`.
@ -35,9 +42,9 @@ App-facing pairing notes live with the PHP app: `repos/ttp/docs/capsule.md`.
|------|-----|
| `src/main/` | Window, session file, TTP HTTP, IPC |
| `src/preload/` | `window.capsule` bridge |
| `src/renderer/` | Login, TTP-styled chrome, search / notifications / messages / profile |
| `src/renderer/` | Login, MFA, TTP-styled chrome, and live API views |
The logged-in header follows the public TTP shell (`text-bg-dark`, FA 6.7.1, Bootstrap 5.3). Search stays visible and centered. Account is a top-right dropdown like the site. Notifications and messages are the same bell / envelope menus. Profile edit covers User CP preferences except email, password, and phone <EFBFBD> those open `{site}/usercp/<EFBFBD>`. Lists are placeholders until the API step.
The logged-in header follows the public TTP shell (`text-bg-dark`, FA 6.7.1, Bootstrap 5.3). Search stays visible and centered. Account is a top-right dropdown like the site. Notifications and messages are the same bell / envelope menus. Profile edit covers User CP preferences except email, password, and phone ? those open `{site}/usercp/?`. Lists load from the site API after sign-in.
## Remote