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

Ouverte Adaptée aux débutants
#128 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
72/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
Active
Stack technique
docker-compose, go
Domaine
cli, documentation

Piste de recherche

Commencez par internal/cmd/login.go, où l’erreur de non-concordance de l’émetteur est renvoyée, et internal/auth/oauth.go, où la non-concordance est détectée. Étendez l’indication de la CLI afin de mentionner FLAGSMITH_API_URL, FLAGSMITH_FRONTEND_URL et la variable de clé d’API propre à l’hôte. Ensuite, mettez à jour la documentation des variables d’environnement afin de répertorier les deux paramètres du serveur dans sa section API.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.
Langage dominant
Go
Étoiles
14
Forks
4
Merge moyen
3 j 7 h
PR mergées (30 j)
4

Préparer son environnement

  • Fournit un Dockerfile ou un fichier Docker Compose
  • Aucun modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de Flagsmith/flagsmith-cli

Toutes les issues de Flagsmith/flagsmith-cli

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.