Skip to content

feat: Harden automatic SSO renewal - #407

Open
cloudsmith-iduffy wants to merge 1 commit into
masterfrom
cloudsmith-iduffy-harden-sso-renewal
Open

feat: Harden automatic SSO renewal#407
cloudsmith-iduffy wants to merge 1 commit into
masterfrom
cloudsmith-iduffy-harden-sso-renewal

Conversation

@cloudsmith-iduffy

Copy link
Copy Markdown
Contributor

Summary

  • schedule SSO refresh from JWT expiry with clock-skew leeway and retry throttling
  • centralize renewal outcomes, refresh-token rotation recovery, and safe keyring persistence
  • preserve usable SSO tokens after transient failures while allowing rejected or expired sessions to fall through to other credential providers
  • skip automatic renewal for authentication commands and emit precise stderr warnings without bypassing normal API error rendering

Validation

  • pytest -q cloudsmith_cli/core/tests/test_sso.py cloudsmith_cli/core/tests/test_keyring.py cloudsmith_cli/core/tests/test_keyring_provider.py cloudsmith_cli/cli/tests/test_decorators.py
  • pre-commit run --files CHANGELOG.md cloudsmith_cli/cli/decorators.py cloudsmith_cli/cli/tests/test_decorators.py cloudsmith_cli/core/credentials/models.py cloudsmith_cli/core/credentials/providers/keyring_provider.py cloudsmith_cli/core/keyring.py cloudsmith_cli/core/sso.py cloudsmith_cli/core/tests/test_keyring.py cloudsmith_cli/core/tests/test_keyring_provider.py cloudsmith_cli/core/tests/test_sso.py

Stacked on #406.

@cloudsmith-iduffy
cloudsmith-iduffy force-pushed the cloudsmith-iduffy-harden-sso-renewal branch 2 times, most recently from 6724cf5 to fd9a17a Compare September 3, 2026 21:21
@cloudsmith-iduffy
cloudsmith-iduffy changed the base branch from cloudsmith-iduffy-remove-auth-token-flag to master September 3, 2026 21:27
@cloudsmith-iduffy
cloudsmith-iduffy marked this pull request as ready for review September 7, 2026 11:07
@cloudsmith-iduffy
cloudsmith-iduffy requested a review from a team as a code owner September 7, 2026 11:07
Copilot AI lite review requested due to automatic review settings September 7, 2026 11:07
@cloudsmith-iduffy

Copy link
Copy Markdown
Contributor Author

@copilot resolve all conflicts

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.

Pull request overview

This PR introduces a more defensive SSO renewal implementation intended to refresh tokens based on JWT expiry (with leeway/throttling) and to better handle refresh-token rotation and transient failures, so the CLI can keep working sessions alive without getting stuck on dead credentials.

Changes:

  • Added a new shared renewal flow (renew_sso_session) with structured outcomes and token-expiry decoding.
  • Adjusted keyring refresh throttling/ordering to better tolerate partial keyring failures and rotation semantics.
  • Added/updated tests and documented the new SSO-refresh behavior in the changelog.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cloudsmith_cli/core/tests/test_sso.py Adds tests for renewal outcomes (rotation success, transient failure reuse, rejection cleanup).
cloudsmith_cli/core/tests/test_keyring.py Extends keyring refresh tests to cover JWT-expiry-driven refresh behavior and token storage ordering.
cloudsmith_cli/core/sso.py Implements JWT-expiry decoding helpers and a new renewal API (renew_sso_session) with structured status handling.
cloudsmith_cli/core/keyring.py Updates refresh-throttle persistence behavior and adds JWT-expiry-aware refresh decision logic.
CHANGELOG.md Documents the new SSO refresh behavior and fallback semantics.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cloudsmith_cli/core/sso.py
Comment thread cloudsmith_cli/core/keyring.py
Comment thread cloudsmith_cli/core/sso.py
@cloudsmith-iduffy
cloudsmith-iduffy force-pushed the cloudsmith-iduffy-harden-sso-renewal branch from fd9a17a to f9e8117 Compare September 7, 2026 11:14

Copilot AI commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve all conflicts

Resolved in 7499df7 after merging master and the remote PR tip; the branch is conflict-free again.

@cloudsmith-iduffy
cloudsmith-iduffy force-pushed the cloudsmith-iduffy-harden-sso-renewal branch from 7499df7 to f9e8117 Compare September 7, 2026 11:22
@cloudsmith-iduffy cloudsmith-iduffy changed the title Harden automatic SSO renewal feat: Harden automatic SSO renewal Sep 7, 2026
@cloudsmith-iduffy
cloudsmith-iduffy force-pushed the cloudsmith-iduffy-harden-sso-renewal branch from f9e8117 to 20a61ff Compare September 7, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants