Empty `AuthToken` Causes Cryptic JWT Parse Error
Maintainer thường phản hồi trong vòng 1 ngà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
- 86/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- authentication, cli
Hướng nghiên cứu
Bắt đầu trong pkg/connectors/microcks_client.go tại refreshAuthToken và theo dõi cách lỗi của nó đến NewClient và CLI. Tái hiện trường hợp AuthToken rỗng sau khi xóa access token đã cấu hình, sau đó xác minh rằng người dùng nhận được thông báo chưa xác thực như mong đợi thay vì lỗi phân tích JWT.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Description
refreshAuthToken in pkg/connectors/microcks_client.go calls
jwt.ParseUnverified(configCtx.User.AuthToken, &claims) without first checking
whether AuthToken is empty. After a fresh install, after logout --token-only,
or whenever the config exists but contains no token, AuthToken is "". The JWT
parser returns an error for the empty string, which propagates all the way up to
NewClient and then to the user as a low-level JWT error rather than a
human-readable "please run microcks login" message.
// microcks_client.go (refreshAuthToken)
if c.RefreshToken == "" {
return nil // ← correctly handles empty refresh token
}
// ... but AuthToken="" is never guarded:
_, _, err = parser.ParseUnverified(configCtx.User.AuthToken, &claims)
if err != nil {
return err // ← surfaces as "token is malformed: ..." to the user
}
How to Reproduce
- Log in, then selectively clear just the access token from the config:
# Edit ~/.config/microcks/config and set auth-token to empty string microcks service list # → "token is malformed: token contains an invalid number of segments" - Compare with the expected UX:
# Expected Error: not authenticated. Run `microcks login` first.
Diagram
flowchart TD
A["NewClient() called"] --> B["ReadLocalConfig()"]
B --> C["configCtx.User.AuthToken = ''"]
C --> D["refreshAuthToken()"]
D --> E{"c.RefreshToken == ''?"}
E -- "no — refresh token exists" --> F["jwt.ParseUnverified('' , &claims)"]
F --> G["jwt.ErrTokenMalformed ← cryptic error"]
G --> H["NewClient returns error to caller"]
H --> I["CLI prints: 'token is malformed: token contains an invalid\nnumber of segments' "]
E -- "yes — no refresh token" --> J["return nil (no-op) "]
subgraph Fix
D --> K{"c.AuthToken == ''?"}
K -- "yes" --> L["return ErrNotAuthenticated "]
K -- "no" --> F
end
style G fill:#e74c3c,color:#fff
style I fill:#e74c3c,color:#fff
style J fill:#2ecc71,color:#fff
style L fill:#2ecc71,color:#fff
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Microcks version or git rev
No response
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
No response
Additional information
No response
- Ngôn ngữ chính
- Go
- Star
- 57
- Fork
- 73
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 28
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microcks/microcks-cli
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microcks/microcks-cli#583 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
microcks/microcks-cli#573 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: YAML parse error in config is silently swallowed, login overwrites all other contextsCó thể đã có người làm @Sarthak-Shreshtha01 đã nhận 5 ngày trước. Đang mởcomponent/cli kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microcks/microcks-cli#572 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
import-dir uploads secondary artifacts before their primary API definitionCó thể đã có người làm @doraem-on đã nhận 11 ngày trước. Đang mởcomponent/cli kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
microcks/microcks-cli#561 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TEST: `ConnectAndGetToken` Returns Error on Non-200 ResponseCó thể đã có người làm @aniket866 đã nhận 14 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microcks/microcks-cli#554 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microcks/microcks-cli
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
agent-review-finding bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jordansmall/spindrift#5281 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Integer parameters equal to 2^63 pass the range check in toInt and wrap to a negative numberĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
github/github-mcp-server#3489 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
dependabot/dependabot-core#16547 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docs/examples still create key ranges in ascending order, which fails in 3.1.0 (follow-up to #1754)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
pg-sharding/spqr#3083 ·
Maintainer thường phản hồi trong vòng 1 ngày