Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Server auth: API tokens for non-browser clients (Home Assistant, scripts)

Aperta
#763 1 commento 1 reazione 0 assegnatari Vedi su GitHub

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

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 and POST /api/shopping_list still 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 a Viewer the 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cooklang/cookcli

Tutte le issue di cooklang/cookcli

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.