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

未关闭 适合新手
#128 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
docker-compose, go
领域
cli, documentation

调研方向

从 internal/cmd/login.go(返回 issuer 不匹配错误的位置)和 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 小时
30 天内合并 PR
4

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Flagsmith/flagsmith-cli 的其他 Issue

查看 Flagsmith/flagsmith-cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。