Skip to content

Fix device token handling - #38

Merged
tiankaima merged 1 commit into
mainfrom
agent/fix-device-login-token-handling
Aug 11, 2026
Merged

Fix device token handling#38
tiankaima merged 1 commit into
mainfrom
agent/fix-device-login-token-handling

Conversation

@tiankaima

Copy link
Copy Markdown
Member

What changed

  • make the CLI a pure OAuth API client by excluding unused openid, profile, and email identity scopes
  • retain offline_access and all discovered API feature scopes
  • accept standard OAuth token responses without requiring an id_token
  • remove unused ID-token parsing and the go-jose dependency
  • add an end-to-end device-flow regression covering discovery, registration, authorization, polling, and credential creation without an ID token

Root cause

The production RFC 8628 device token response correctly contains access/refresh tokens and granted scopes but no OIDC ID token. The CLI does not consume identity claims, yet it requested openid and rejected the otherwise valid OAuth response when id_token was absent. Its old parser also inspected ID-token claims without signature verification, so retaining that unused path provided no security value.

Impact

life-ustc account login --device now saves the issued OAuth credentials after approval. Browser login uses the same API/offline scope set and no longer depends on an unused OIDC response.

Validation

  • full mocked device flow succeeds with no id_token
  • production accepts the filtered 45-scope registration/device-authorization request
  • go test ./internal/auth
  • go test -race ./...
  • go vet ./...
  • golangci-lint run ./...
  • OpenAPI provenance verification and generation
  • go build -buildvcs=false -ldflags "-X github.com/Life-USTC/CLI/internal/cmd/root.version=dev" -o life-ustc ./cmd/life-ustc

@tiankaima
tiankaima marked this pull request as ready for review August 11, 2026 15:43
@tiankaima
tiankaima merged commit c79f583 into main Aug 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant