microcks / microcks/microcks-cli
Missing Verification for Automatic OIDC Access Token Refreshing and JWT Expiration Claim Parsing
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 52
- フォーク
- 68
- 平均マージ
- 6時間 54分
- マージ済み PR(30日)
- 10
説明
Describe the bug
-
Location: pkg/connectors/microcks_client.go ->
refreshAuthToken -
Detailed Description:
When you run the CLI for a long time (like keeping it active in the background), the security token it got when you logged in will eventually expire. To prevent commands from failing, we have code that reads the cached security token, parses it to see when it expires, and automatically requests a new one from the server if it's running out of time.Currently, we have zero tests checking this check-and-refresh logic. If a bug is introduced here, the CLI will suddenly stop working after a while and throw unauthorized errors (like HTTP 401) out of nowhere. We need to make sure the token checks are accurate and that the refresh requests are triggered correctly.
-
Test Requirements:
- Verify that a valid, fresh token does not trigger a refresh.
- Verify that a token close to expiry or already expired triggers the refresh server call.
- Check that the CLI successfully updates the local configuration file with the new token.
- Make sure the CLI handles cases where the refresh token itself has expired and tells the user to log in again.
Simulation Diagram
sequenceDiagram
autonumber
actor Test as Test Runner
participant MC as microcksClient
participant mockKC as Mock Keycloak Server (httptest)
Test->>MC: Trigger refreshAuthToken() with Expired JWT
activate MC
MC->>MC: Parse JWT Claims & Detect Expiration (exp <= now)
Note over MC: Expiration detected. Initiating refresh flow...
MC->>mockKC: POST /protocol/openid-connect/token (refresh_token grant)
activate mockKC
mockKC-->>MC: HTTP 200 OK (New Auth & Refresh Tokens)
deactivate mockKC
MC->>MC: Save new tokens to localconfig YAML file
MC-->>Test: Success (Token Refreshed)
deactivate MC
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
pkg/connectors/microcks_client.go の refreshAuthToken から開始し、JWT の有効期限がどのように解析され、refresh リクエストがどのように行われるかを確認します。httptest のモック Keycloak サーバーを使用して、新しいトークン、有効期限が近いトークン、期限切れのトークン、期限切れの refresh token のケースを網羅します。期待される refresh 動作が検証され、新しいトークンがローカル設定 YAML に保存され、必要な場合に再ログインが必要であることが報告されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- go
- 領域
- authentication, cli, testing
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 活発
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 72/100