Skip to content

feat(auth)!: surface refresh-token availability on Credential/auth status - #79

Merged
jpage-godaddy merged 3 commits into
mainfrom
feat/auth-status-refreshable
Aug 4, 2026
Merged

jpage-godaddy merged 3 commits into
mainfrom
feat/auth-status-refreshable

Conversation

@jpage-godaddy

@jpage-godaddy jpage-godaddy commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • PkceAuthProvider::status() only checks the access token's own expires_at, so auth status reports a credential as fully expired even when a valid refresh token is on file and the next real command would silently renew it via existing_token() without an interactive re-login.
  • Adds Credential::refreshable: bool (token.refresh_token.is_some()), threaded through to AuthStatusEntry::refreshable and AuthLoginResult::refreshable so auth status/auth login output stays consistent with each other (mirrors the existing scopes pattern).
  • refreshable reflects presence, not verified validity — refresh tokens here are opaque with no discoverable TTL, so there's no way to confirm a refresh will succeed without attempting it. (Doc comments on all three types were reworded during review to state this explicitly rather than implying a renewal guarantee.)
  • Marks AuthLoginResult and AuthStatusEntry #[non_exhaustive] (added during review). Both are output-only DTOs built exclusively inside this crate; neither gddy nor gdx construct them via struct literal, so this closes off needing another breaking release the next time a field is added to either. Credential (the AuthProvider trait's return type, built by hand in ~20 call sites across both known consumers) is intentionally left exhaustive — making it non_exhaustive would need a constructor/builder API first, which is out of scope here.

Breaking change

  • New field: Credential, AuthStatusEntry, and AuthLoginResult are public structs without #[non_exhaustive] before this PR; the new refreshable field breaks any downstream struct literal that doesn't use ..Default::default() or list every field. Updated the 4 affected assertions in cli-engine/tests/foundation.rs.
  • #[non_exhaustive]: AuthLoginResult and AuthStatusEntry can no longer be constructed via struct literal (with or without ..Default::default()) or exhaustively pattern-matched from outside this crate. Rewrote the two affected re-export smoke tests in foundation.rs to obtain instances through the real login/status flow instead.

Test plan

  • cargo check --all-targets (default features and --features pkce-auth)
  • cargo clippy --all-targets -- -D warnings (both feature sets)
  • cargo test --all-targets — 613 passed (default features), 665 passed (--features pkce-auth)
  • cargo fmt --check
  • Added build_credential_sets_refreshable_when_refresh_token_present / build_credential_leaves_refreshable_false_without_refresh_token in auth::pkce::tests (refined during review)

…atus

PkceAuthProvider::status() only checks the access token's own expiry, so
`auth status` reports a token as fully expired even when a valid refresh
token is on file and the next real command would silently renew it
without an interactive re-login.

Adds Credential::refreshable (true when a refresh token is present),
threaded through to AuthStatusEntry and AuthLoginResult so `auth status`
and `auth login` output stays consistent.

BREAKING CHANGE: Credential, AuthStatusEntry, and AuthLoginResult are
public, non-exhaustive-less structs gaining a new field; any downstream
struct literal constructing them without `..Default::default()` (or
listing every field) will need updating.

Copilot AI left a comment

Copy link
Copy Markdown

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 updates the cli_engine auth surface so auth status / auth login can report whether a cached credential is refreshable (i.e., a refresh token is present), avoiding the current “fully expired” interpretation when an access token is expired but can be silently refreshed.

Changes:

  • Adds Credential::refreshable and threads it through AuthLoginResult and AuthStatusEntry.
  • Sets Credential.refreshable for PKCE-based credentials based on stored refresh-token presence.
  • Updates integration tests to account for the new public fields and JSON output shape.

Reviewed changes

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

File Description
cli-engine/src/auth/credential.rs Adds Credential::refreshable with serde defaults and documentation.
cli-engine/src/auth/pkce.rs Populates Credential.refreshable from the stored token’s refresh-token presence.
cli-engine/src/auth/commands.rs Extends auth login / auth status output structs and wiring to include refreshable.
cli-engine/tests/foundation.rs Updates assertions and public-surface construction tests for the new fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli-engine/src/auth/credential.rs Resolved
Comment thread cli-engine/src/auth/commands.rs Resolved
Comment thread cli-engine/src/auth/pkce.rs Resolved
… coverage

Copilot review on #79 flagged doc wording that read as a guarantee
("can be silently renewed", "will renew itself transparently") when
refreshable only reflects that a refresh token was issued, not that a
renewal attempt would succeed. Also adds the missing unit test coverage
for build_credential setting refreshable from token.refresh_token.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Both are output-only DTOs built exclusively inside this crate
(login_and_build_with_scopes/status_result/to_status_entry) — neither
gddy nor gdx construct them via struct literal, unlike Credential (the
AuthProvider trait's return type, built by hand in ~20 call sites across
both consumers, which stays exhaustive for now). Adding this now, while
#79 is already a breaking release, avoids needing another major bump the
next time a field is added to either.

Rewrites the two re-export smoke tests in foundation.rs to obtain
instances through the real login/status flow instead of a struct
literal, since non_exhaustive blocks that from outside the crate.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (1)

cli-engine/src/auth/commands.rs:19

  • The PR description says AuthLoginResult/AuthStatusEntry are public structs without #[non_exhaustive] and that the breaking change is only the new refreshable field. This diff also adds #[non_exhaustive], which is an additional breaking API change (external crates can no longer construct these structs via literals and cannot exhaustively destructure them). Either update the PR description/release notes to reflect this, or drop #[non_exhaustive] if it wasn’t intended.
/// result and should not construct it directly — `#[non_exhaustive]` lets
/// this framework add fields (as it did for [`refreshable`](Self::refreshable))
/// without another breaking release.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]

@jpage-godaddy
jpage-godaddy merged commit d88d30c into main Aug 4, 2026
4 checks passed
@jpage-godaddy
jpage-godaddy deleted the feat/auth-status-refreshable branch August 4, 2026 16:15
@github-actions github-actions Bot mentioned this pull request Aug 4, 2026
jpage-godaddy pushed a commit that referenced this pull request Aug 4, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>cli-engine: 0.7.0</summary>

##
[0.7.0](cli-engine-v0.6.1...cli-engine-v0.7.0)
(2026-08-04)


### ⚠ BREAKING CHANGES

* **auth:** surface refresh-token availability on Credential/auth status
([#79](#79))

### Features

* **auth:** surface refresh-token availability on Credential/auth status
([#79](#79))
([d88d30c](d88d30c))
* **command:** add opt-in pagination via CommandSpec::with_pagination
([#81](#81))
([d829f90](d829f90))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants