From 7bc1f71db59be17601270fa00b2275938bf1def2 Mon Sep 17 00:00:00 2001 From: Jacob Page Date: Wed, 8 Jul 2026 15:16:17 -0700 Subject: [PATCH 1/5] fix: request offline_access scope for refresh tokens, centralize hosting 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. --- CLAUDE.md | 2 +- rust/src/environments/mod.rs | 2 +- rust/src/hosting/nodejs/mod.rs | 9 +++++---- rust/src/hosting/nodejs/scopes.rs | 10 ---------- rust/src/scopes.rs | 29 +++++++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 16 deletions(-) delete mode 100644 rust/src/hosting/nodejs/scopes.rs diff --git a/CLAUDE.md b/CLAUDE.md index e08df579..32843ba9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -42,7 +42,7 @@ rust/src/ nodejs/ mod.rs — hosting nodejs command group client.rs — Node.js Hosting REST client - scopes.rs — OAuth scope constants + scopes.rs — centralized OAuth scope registry (all commands draw from this) webhook/mod.rs — webhook commands config/mod.rs — godaddy.toml read/write auth.rs — auth module registration diff --git a/rust/src/environments/mod.rs b/rust/src/environments/mod.rs index 44affbd5..6adb67f6 100644 --- a/rust/src/environments/mod.rs +++ b/rust/src/environments/mod.rs @@ -36,8 +36,8 @@ pub const DEFAULT_ENV: &str = "prod"; /// subset; commands needing more declare them and the provider steps up. Drawn /// from the central [`crate::scopes`] registry (which the OAuth client mirrors). pub const DEFAULT_OAUTH_SCOPES: &[&str] = &[ - crate::scopes::APP_REGISTRY_READ, crate::scopes::DOMAINS_READ, + crate::scopes::OFFLINE_ACCESS, ]; pub const REDIRECT_URI: &str = "http://localhost:7443/callback"; pub const APP_ID: &str = "gddy"; diff --git a/rust/src/hosting/nodejs/mod.rs b/rust/src/hosting/nodejs/mod.rs index afa87f6d..430f4886 100644 --- a/rust/src/hosting/nodejs/mod.rs +++ b/rust/src/hosting/nodejs/mod.rs @@ -1,5 +1,4 @@ pub mod client; -pub mod scopes; use cli_engine::{ CliCoreError, CommandContext, CommandResult, CommandSpec, GroupSpec, NextAction, @@ -12,9 +11,11 @@ use crate::{ output_schema::output_schema, }; -use self::scopes::{ - APPS_CREATE, APPS_DELETE, APPS_READ, APPS_UPDATE, CODE_WRITE, DEPLOY_EXECUTE, LOGS_READ, - SECRETS_WRITE, +use crate::scopes::{ + HOSTING_APPS_CREATE as APPS_CREATE, HOSTING_APPS_DELETE as APPS_DELETE, + HOSTING_APPS_READ as APPS_READ, HOSTING_APPS_UPDATE as APPS_UPDATE, + HOSTING_CODE_WRITE as CODE_WRITE, HOSTING_DEPLOY_EXECUTE as DEPLOY_EXECUTE, + HOSTING_LOGS_READ as LOGS_READ, HOSTING_SECRETS_WRITE as SECRETS_WRITE, }; output_schema!(HostingAppSummary { diff --git a/rust/src/hosting/nodejs/scopes.rs b/rust/src/hosting/nodejs/scopes.rs deleted file mode 100644 index c0699f38..00000000 --- a/rust/src/hosting/nodejs/scopes.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! OAuth scopes for the Node.js Hosting Public API. - -pub const APPS_READ: &str = "hosting.paas.apps:read"; -pub const APPS_CREATE: &str = "hosting.paas.apps:create"; -pub const APPS_UPDATE: &str = "hosting.paas.apps:update"; -pub const APPS_DELETE: &str = "hosting.paas.apps:delete"; -pub const CODE_WRITE: &str = "hosting.paas.code:write"; -pub const DEPLOY_EXECUTE: &str = "hosting.paas.deploy:execute"; -pub const SECRETS_WRITE: &str = "hosting.paas.secrets:write"; -pub const LOGS_READ: &str = "hosting.paas.logs:read"; diff --git a/rust/src/scopes.rs b/rust/src/scopes.rs index ec9ec2a2..3734c602 100644 --- a/rust/src/scopes.rs +++ b/rust/src/scopes.rs @@ -52,6 +52,18 @@ macro_rules! declare_scopes { }; } +/// OIDC directive scope requesting a `refresh_token` alongside the access +/// token. Requested at login by default (see +/// [`crate::environments::DEFAULT_OAUTH_SCOPES`]). +/// +/// Deliberately declared outside [`declare_scopes!`]/[`ALL`]: unlike the +/// scopes below, it isn't a `resource:action` permission grant, so it fails +/// the `resource:action` shape the module tests enforce for `ALL`. It still +/// must be registered on the CLI's OAuth client server-side, or the +/// authorization server will refuse or silently drop it just like any other +/// unregistered scope. +pub const OFFLINE_ACCESS: &str = "offline_access"; + // DON'T FORGET! If you add a scope here, you must also register it on the CLI's OAuth client. declare_scopes! { /// Read the caller's registered applications. Requested at login by default @@ -75,6 +87,23 @@ declare_scopes! { DOMAINS_CREATE => "domains.domain:create", /// Replace a domain's nameservers (`domain nameservers set`). DOMAINS_NAMESERVER_UPDATE => "domains.nameserver:update", + + /// Read Node.js Hosting apps (`hosting nodejs app list/get`). + HOSTING_APPS_READ => "hosting.paas.apps:read", + /// Create a Node.js Hosting app (`hosting nodejs app create`). + HOSTING_APPS_CREATE => "hosting.paas.apps:create", + /// Update a Node.js Hosting app (`hosting nodejs app update`). + HOSTING_APPS_UPDATE => "hosting.paas.apps:update", + /// Delete a Node.js Hosting app (`hosting nodejs app delete`). + HOSTING_APPS_DELETE => "hosting.paas.apps:delete", + /// Upload code to a Node.js Hosting app (`hosting nodejs app deploy`/`upload`). + HOSTING_CODE_WRITE => "hosting.paas.code:write", + /// Trigger a Node.js Hosting deploy (`hosting nodejs app deploy`). + HOSTING_DEPLOY_EXECUTE => "hosting.paas.deploy:execute", + /// Write Node.js Hosting app secrets (`hosting nodejs secret set/delete`). + HOSTING_SECRETS_WRITE => "hosting.paas.secrets:write", + /// Read Node.js Hosting app logs (`hosting nodejs app logs`). + HOSTING_LOGS_READ => "hosting.paas.logs:read", } #[cfg(test)] From 09c468eb92afbc08d7031589d517f109b4a664ef Mon Sep 17 00:00:00 2001 From: Jacob Page Date: Wed, 8 Jul 2026 15:21:29 -0700 Subject: [PATCH 2/5] style: run cargo fmt on DEFAULT_OAUTH_SCOPES Fixes the cicd rustfmt check that failed on PR #85. --- rust/src/environments/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rust/src/environments/mod.rs b/rust/src/environments/mod.rs index 6adb67f6..d1d4d80e 100644 --- a/rust/src/environments/mod.rs +++ b/rust/src/environments/mod.rs @@ -35,10 +35,8 @@ pub const DEFAULT_ENV: &str = "prod"; /// Scopes requested at login by default. The authorization server may grant a /// subset; commands needing more declare them and the provider steps up. Drawn /// from the central [`crate::scopes`] registry (which the OAuth client mirrors). -pub const DEFAULT_OAUTH_SCOPES: &[&str] = &[ - crate::scopes::DOMAINS_READ, - crate::scopes::OFFLINE_ACCESS, -]; +pub const DEFAULT_OAUTH_SCOPES: &[&str] = + &[crate::scopes::DOMAINS_READ, crate::scopes::OFFLINE_ACCESS]; pub const REDIRECT_URI: &str = "http://localhost:7443/callback"; pub const APP_ID: &str = "gddy"; From d31b096db99f911e924375153260aa2a548e70d4 Mon Sep 17 00:00:00 2001 From: Jacob Page Date: Wed, 8 Jul 2026 15:23:32 -0700 Subject: [PATCH 3/5] fix: restore APP_REGISTRY_READ to default OAuth scopes 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. --- rust/src/environments/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rust/src/environments/mod.rs b/rust/src/environments/mod.rs index d1d4d80e..0793ed85 100644 --- a/rust/src/environments/mod.rs +++ b/rust/src/environments/mod.rs @@ -35,8 +35,11 @@ pub const DEFAULT_ENV: &str = "prod"; /// Scopes requested at login by default. The authorization server may grant a /// subset; commands needing more declare them and the provider steps up. Drawn /// from the central [`crate::scopes`] registry (which the OAuth client mirrors). -pub const DEFAULT_OAUTH_SCOPES: &[&str] = - &[crate::scopes::DOMAINS_READ, crate::scopes::OFFLINE_ACCESS]; +pub const DEFAULT_OAUTH_SCOPES: &[&str] = &[ + crate::scopes::APP_REGISTRY_READ, + crate::scopes::DOMAINS_READ, + crate::scopes::OFFLINE_ACCESS, +]; pub const REDIRECT_URI: &str = "http://localhost:7443/callback"; pub const APP_ID: &str = "gddy"; From ce7bdc9b93c9c9d998b9c146977e76d6ab67c37c Mon Sep 17 00:00:00 2001 From: Jacob Page Date: Wed, 8 Jul 2026 15:27:37 -0700 Subject: [PATCH 4/5] docs: clarify scopes::ALL excludes OFFLINE_ACCESS 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. --- rust/src/scopes.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rust/src/scopes.rs b/rust/src/scopes.rs index 3734c602..849cf9fb 100644 --- a/rust/src/scopes.rs +++ b/rust/src/scopes.rs @@ -39,10 +39,15 @@ macro_rules! declare_scopes { ($( $(#[$doc:meta])* $name:ident => $value:literal ),+ $(,)?) => { $( $(#[$doc])* pub const $name: &str = $value; )+ - /// Every OAuth scope the CLI may request, and therefore the exact set its - /// OAuth client must be registered for. Auto-derived from the constants - /// declared in [`declare_scopes!`] — keep the client's registration in sync - /// with this list. + /// Every `resource:action` permission scope the CLI may request. Auto-derived + /// from the constants declared in [`declare_scopes!`] — keep the client's + /// registration in sync with this list. + /// + /// NOT the complete set of scopes requiring OAuth client registration: + /// [`OFFLINE_ACCESS`] is a directive scope (not a `resource:action` permission) + /// and is deliberately excluded, but still must be registered on the client + /// server-side. Diff the client's configuration against `ALL` *plus* + /// [`OFFLINE_ACCESS`], not `ALL` alone. /// /// Not referenced by production code (the individual constants are what /// commands use); it exists as the authoritative registry to diff against From 782bc9e60b87f349993516ce901a947466bbfa29 Mon Sep 17 00:00:00 2001 From: Jacob Page Date: Wed, 8 Jul 2026 15:32:15 -0700 Subject: [PATCH 5/5] docs: fix module-level scopes.rs docs to match ALL's actual scope 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. --- rust/src/scopes.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/rust/src/scopes.rs b/rust/src/scopes.rs index 849cf9fb..8715fd6c 100644 --- a/rust/src/scopes.rs +++ b/rust/src/scopes.rs @@ -13,15 +13,23 @@ //! //! So: **every scope the CLI uses is declared here, once**, and commands draw //! from these constants rather than spelling out string literals. The [`ALL`] -//! slice is derived from the same declarations, so it is always the complete, -//! authoritative list of scopes the OAuth client must be registered for — a -//! single place to diff against the client's configuration. +//! slice is derived from the same declarations, so it is always the complete +//! list of `resource:action` *permission* scopes the OAuth client must be +//! registered for — a single place to diff against the client's configuration. +//! +//! `ALL` does NOT cover every scope requiring client registration, though: +//! directive scopes like [`OFFLINE_ACCESS`] aren't `resource:action` grants, so +//! they're declared outside [`declare_scopes!`]/`ALL` but still need the same +//! server-side registration. When syncing the OAuth client's configuration, +//! diff against `ALL` *plus* every such standalone constant, not `ALL` alone. //! //! # Adding a scope (READ THIS) //! -//! 1. Add a constant to the [`declare_scopes!`] block below. It is automatically -//! included in [`ALL`] — you cannot add a scope constant without registering -//! it in the list. +//! 1. Add a constant to the [`declare_scopes!`] block below (or, for a directive +//! scope that isn't a `resource:action` permission, declare it standalone +//! like [`OFFLINE_ACCESS`]). Constants in `declare_scopes!` are automatically +//! included in [`ALL`] — you cannot add one there without registering it in +//! the list. //! 2. Reference the new constant from the command via `.with_scopes(&[scopes::…])`. //! 3. **Register the same scope on the CLI's OAuth client**, or it will be //! ungrantable at runtime.