`flagsmith login` fails on a self-hosted instance that isn't served at `http://localhost:8000`

Aperta Adatta ai principianti
#128 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker-compose, go
Ambito
cli, documentation

Direzione di ricerca

Inizia da internal/cmd/login.go, dove viene restituito l’errore di mismatch dell’issuer, e da internal/auth/oauth.go, dove il mismatch viene rilevato. Estendi il suggerimento della CLI per indicare FLAGSMITH_API_URL, FLAGSMITH_FRONTEND_URL e la variabile della chiave API associata all’host. Quindi aggiorna la documentazione delle variabili d’ambiente per elencare entrambe le impostazioni del server nella sezione API.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Self-hosted 2.294.0 (docker.flagsmith.com/flagsmith/flagsmith:2.294.0, Docker Compose) with the API published on localhost:18101, and @flagsmith/cli 2.0.0.

$ flagsmith login --api-url http://localhost:18101 --no-browser
Error: authorization server metadata is for http://localhost:8000, not http://localhost:18101 — use the instance's canonical API URL

The instance's discovery document still describes the default URLs:

$ curl -s http://localhost:18101/.well-known/oauth-authorization-server
{"issuer": "http://localhost:8000", "authorization_endpoint": "http://localhost:8080/oauth/authorize/", "token_endpoint": "http://localhost:8000/o/token/", ...}

The server builds it from FLAGSMITH_API_URL and FLAGSMITH_FRONTEND_URL, which default to http://localhost:8000 and http://localhost:8080 (common.py L982-L985, oauth2_metadata/views.py L46-L47). The CLI is right to refuse the mismatch (oauth.go L69-L71), but the error gives no hint: browserLogin only adds one for ErrNoDiscovery (login.go L85-L90). "Canonical API URL" points at the CLI flag, when the fix is a server setting.

The docs don't help either. The environment variables page lists FLAGSMITH_API_URL only as a frontend variable (with an /api/v1/ example) and doesn't mention FLAGSMITH_FRONTEND_URL.

The default docker-compose.yml sets neither, so on port 8000 the issuer matches but authorization_endpoint points at 8080, while the dashboard is on 8000. I haven't tried login on port 8000 itself. The run locally with a coding agent guide already says to use an organisation API key, not flagsmith login.

Workaround:

export FLAGSMITH_API_URL=http://localhost:18101
export FLAGSMITH_API_KEY_localhost_18101=<organisation API key>

Suggestions:

  1. When the issuer doesn't match, add a hint that names the server settings (FLAGSMITH_API_URL, FLAGSMITH_FRONTEND_URL) and the host-scoped key variable, as tooOldForOAuthHint does for older servers (#76).
  2. Document both settings in the API section of the environment variables page.
Lingua principale
Go
Stelle
14
Fork
4
Merge medio
3g 7h
PR unite (30g)
4

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

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 Flagsmith/flagsmith-cli

Tutte le issue di Flagsmith/flagsmith-cli

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.