Server auth: API tokens for non-browser clients (Home Assistant, scripts)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- api, authentication, cli, security
Direzione di ricerca
Start by reading the server authentication middleware, the users-file watcher, and revoked.rs to understand how sessions and role changes are handled. Then trace the cook server user command to see where token add, list, and revoke commands would fit. Done means hashed tokens authenticate API requests as their user, revocation takes effect on the next request, and /api-docs explains the flow.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Once a users file exists, every write needs a signed-in session — and the only way to get one is the browser login form (HttpOnly session cookie). Non-browser clients have no way to authenticate, so on a server with sign-in enabled they're read-only:
- homeassistant-cookcli —
add_recipe_to_shopping_list,clear_shopping_list, removing recipes, and ticking ingredients off (/api/shopping_list/add|remove|clear|check|uncheck) all get 401. Reads andPOST /api/shopping_liststill work since they're open. - curl / cron / shell scripts against the API.
Users who self-host behind a NAS or reverse proxy are exactly the ones who turn sign-in on and want home automation.
Proposal
Bearer tokens tied to a user, so they inherit that user's role (Reader / Shopper / Editor / Admin) and the existing middleware capability checks apply unchanged:
cook server token add <user> [--name home-assistant] # prints the token once
cook server token list
cook server token revoke <name>
- Request:
Authorization: Bearer <token>; the middleware resolves it to aViewerthe same way it does a session cookie. - Store only a hash next to the users file; picked up by the existing watcher, revocation applies on the next request (like role changes and
revoked.rs). - A token never sets a cookie, so it doesn't widen the browser's CSRF surface.
- Typical setup:
cook server user add ha --role shopper+ a token for it — least privilege for automations. - Document in
/api-docs.
Then
homeassistant-cookcli adds an optional token field to its config flow and sends the header.
- Lingua principale
- Rust
- Stelle
- 1.4k
- Fork
- 120
- Merge medio
- 1g 22h
- PR unite (30g)
- 128
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cooklang/cookcli
-
Editor save status and save errors are in English whatever the site's languageForse già presa @LeMyst l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Shopping list counts a recipe twice when three or more menus reference each other in a ringForse già presa @LeMyst l’ha presa 1 giorno fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
feat(server): tag pages, so a recipe can belong to several collectionsForse già presa @LeMyst l’ha presa 2 giorni fa. Apertaarea: server feature request
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
wontfix
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
cooklang/cookcli#784 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
area: pantry feature request needs discussion
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di cooklang/cookcli
Issue simili
-
Add a just recipe that runs the workflow linters locallyForse già presa @sgamelin l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
good first issue security
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
-
Status bar: a progress line that keeps the same text (import at 0%) ages out after 8 s and blinksApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
transit-audio/transit#216 ·
-
area: effects devices enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
suhina-daw/suhina-daw#1060 ·
I maintainer di solito rispondono entro 1 giorno