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

オープン 初心者向け
#128 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker-compose, go
領域
cli, documentation

調査の方向性

issuer の不一致エラーが返される internal/cmd/login.go と、不一致が検出される internal/auth/oauth.go から始めます。CLI のヒントを拡張して、FLAGSMITH_API_URL、FLAGSMITH_FRONTEND_URL、およびホスト単位の API キー変数を明記します。次に、環境変数のドキュメントを更新し、API セクションに両方のサーバー設定を追加します。

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Go
スター
14
フォーク
4
平均マージ
3日 7時間
マージ済み PR(30日)
4

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Flagsmith/flagsmith-cli のほかの issue

Flagsmith/flagsmith-cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。