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

Đang mở Phù hợp với người mới
#128 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker-compose, go
Lĩnh vực
cli, documentation

Hướng nghiên cứu

Bắt đầu với internal/cmd/login.go, nơi trả về lỗi không khớp issuer, và internal/auth/oauth.go, nơi phát hiện sự không khớp. Mở rộng gợi ý của CLI để nêu FLAGSMITH_API_URL, FLAGSMITH_FRONTEND_URL và biến khóa API theo phạm vi host. Sau đó, cập nhật tài liệu biến môi trường để liệt kê cả hai cấu hình máy chủ trong phần API.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Go
Star
14
Fork
4
Merge trung bình
3 ngày 7 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Flagsmith/flagsmith-cli

Tất cả issue của Flagsmith/flagsmith-cli

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.