Skip to content

fix(auth): distinguish invalid_grant from transient SSO renewal errors - #229

Merged
Maotechh merged 1 commit into
HeZeBang:masterfrom
Maotechh:fix/sso-renewal-error-classification
Nov 24, 2026
Merged

Maotechh merged 1 commit into
HeZeBang:masterfrom
Maotechh:fix/sso-renewal-error-classification

Conversation

@Maotechh

Copy link
Copy Markdown
Collaborator

Summary

  • Classify GeekPie Uni-Auth (Casdoor) refresh-token failures in UniAuthService via structured SsoRefreshException (SsoRefreshErrorKind.invalidGrant vs SsoRefreshErrorKind.transient), with a 15s timeout on refresh requests and empty-string protection when handling rotated refresh_token.
  • Return a typed SessionRenewalResult (skipped, renewed, unavailable, expired, transientError) from AuthService.tryRenewSession() instead of swallowing all exceptions into false.
  • Update startup renewal in lib/main.dart to show 登录已过期,请重新登录 only when Casdoor explicitly rejects the refresh grant (invalid_grant / invalid_token), avoiding false expiry prompts on offline launches, timeouts, proxy issues, or 5xx outages.
  • Update SyncService 401 forced-renewal handling to report a network error (网络异常,续期失败,请稍后重试) on transient refresh failures instead of 登录已过期,请重新登录.
  • Emit redacted diagnostic traces (including exception type, HTTP status, and OAuth error code — never token values) for transport/timeout/storage renewal failures, and add access_token / refresh_token / id_token to DebugLogger sensitive-key redaction.

Verification

  • flutter analyze --no-pub: No issues found
  • flutter test --no-pub: 1086/1086 passed (including new unit tests in test/sso_renewal_test.dart and test/sync_service_test.dart)

Copilot AI balanced review requested due to automatic review settings November 24, 2026 17:23
@github-project-automation github-project-automation Bot moved this to Backlog in TechPie Nov 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Maotechh
Maotechh merged commit a72e681 into HeZeBang:master Nov 24, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in TechPie Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants