Skip to content

fix: request offline_access scope for refresh tokens, centralize hosting scopes - #85

Merged
jpage-godaddy merged 5 commits into
rust-portfrom
offline-access-refresh-tokens
Jul 8, 2026
Merged

jpage-godaddy merged 5 commits into
rust-portfrom
offline-access-refresh-tokens

Conversation

@jpage-godaddy

Copy link
Copy Markdown
Collaborator

Summary

  • Request the offline_access scope by default at login so the authorization server actually issues a refresh_token — cli-engine already implements refresh-token storage and silent refresh (PkceAuthProvider), but without this scope every expired access token forced a full interactive browser re-login.
  • Fold the Node.js Hosting scope constants (hosting/nodejs/scopes.rs) into the central rust/src/scopes.rs registry as HOSTING_* constants, so they're covered by the registry's uniqueness/well-formedness test and there's a single source of truth for every scope the CLI requests.

Test plan

  • cargo build
  • cargo test scopes (well-formedness test passes, now covers hosting scopes too)
  • cargo clippy -- -D warnings
  • Manual: confirm the auth platform's OAuth client is configured to allow offline_access, then run gddy auth login, complete the flow, and confirm a refresh token is now stored and used silently once the access token expires

…ing scopes

cli-engine already implements refresh-token storage and silent refresh, but
the CLI never requested the offline_access scope our auth platform requires
to receive one, so every expired token forced a full browser re-login.

Also folds the Node.js Hosting scope constants into the central scopes.rs
registry so they're covered by its uniqueness/well-formedness test.

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 updates the CLI’s OAuth scope handling to ensure refresh tokens are issued (via offline_access) and consolidates Node.js Hosting scopes into the central scope registry so they’re validated and managed in one place.

Changes:

  • Add offline_access as a default login scope to enable refresh token issuance and silent refresh.
  • Move Node.js Hosting OAuth scope constants into rust/src/scopes.rs as HOSTING_* entries and update hosting code to use them.
  • Remove the now-redundant hosting/nodejs/scopes.rs module and update docs to reflect the centralized scope registry.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rust/src/scopes.rs Adds OFFLINE_ACCESS and centralizes Node.js Hosting scopes into the main registry.
rust/src/hosting/nodejs/scopes.rs Removes the per-module hosting scope constants (now centralized).
rust/src/hosting/nodejs/mod.rs Switches hosting commands to use centralized HOSTING_* scope constants.
rust/src/environments/mod.rs Updates default login scopes to include offline_access (but currently drops APP_REGISTRY_READ).
CLAUDE.md Updates source-layout docs to point to the centralized scopes registry.

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

Comment thread rust/src/environments/mod.rs Resolved
Fixes the cicd rustfmt check that failed on PR #85.
application list/info call ctx.credential() with no scope step-up,
so they depend entirely on the login-default scope set. It had been
dropped from DEFAULT_OAUTH_SCOPES, which would break both commands
with an insufficient-scope error after a fresh login.

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread rust/src/scopes.rs Resolved
ALL's docstring claimed to be the complete set of scopes requiring
OAuth client registration, but OFFLINE_ACCESS is deliberately excluded
from it while still needing registration. Spell that out so a future
sync of client registration from ALL doesn't miss it.

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread rust/src/scopes.rs Resolved
The module doc still described ALL as the complete/authoritative set
of scopes needing OAuth client registration, contradicting the note
added on OFFLINE_ACCESS/ALL itself. Align both: ALL is resource:action
permission scopes only; directive scopes need registration too but
live outside declare_scopes!/ALL.

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

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

@jpage-godaddy
jpage-godaddy merged commit b6d49c7 into rust-port Jul 8, 2026
2 checks passed
@jpage-godaddy
jpage-godaddy deleted the offline-access-refresh-tokens branch July 8, 2026 22:37
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