Skip to content

Name a refused credential store instead of asking for a login - #866

Closed
robzolkos wants to merge 4 commits into
mainfrom
fix/keyring-refused-hint
Closed

robzolkos wants to merge 4 commits into
mainfrom
fix/keyring-refused-hint

Conversation

@robzolkos

@robzolkos robzolkos commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A customer runs the CLI from Codex on Windows. Codex's default Windows sandbox (MXC) refuses access to Windows Credential Manager. The CLI's keyring probe gets Access is denied., falls back to an empty credentials.json, and reports the miss as auth_required with the hint Run: basecamp auth login.

That remedy is wrong. The person is already logged in, and the login sits in the vault the sandbox won't open. A new login inside the sandbox would be refused the same way, or stored somewhere the next sandboxed run can't read either. The same wall shows up for gh inside Codex on Windows (openai/codex#21821).

Change

  • Classify a refused store. storeRefused matches any store error that wraps fs.ErrPermission. That covers a keyring probe refused with a permission error, which credstore carries in the fallback miss, and a credentials file that can't be read for lack of permission.

    • On Windows, syscall.Errno maps ERROR_ACCESS_DENIED to fs.ErrPermission.
    • On Unix, EACCES and EPERM map to it.
    • An error already classified as something other than an auth failure keeps its class.
  • unreadable checks this first. A refused probe also reads as ErrNoCredential, so the order matters. The error stays auth_required, and its message now says "the system credential store refused access" alongside the OS's own error. The hint is CredentialStoreRefusedHint, which lists only remedies any account can use:

    The system credential store refused this process access, as AI agent sandboxes do. Run the CLI outside the sandbox; or log in outside it with BASECAMP_NO_KEYRING=1 and XDG_CONFIG_HOME set to a directory the sandbox can read and write, and give the agent the same two settings; or connect the agent to Basecamp's hosted MCP server (https://basecamp.com/ai). A token you already have also works in BASECAMP_TOKEN

    It doesn't send anyone to create a personal access token. A test pins that.

  • CheckAuthenticated returns that error for a refused store. Before, it returned false, nil, so the wizard, people, mcp and completion gates read a refused store as "nothing stored" and offered a login.

  • README: a new "AI agent sandboxes" section under Authentication. It covers:

    It also links auth login/status/doctor hang forever (no timeout) when keyring's D-Bus handshake stalls; BASECAMP_NO_KEYRING=1 works but is undocumented #800, which asks for BASECAMP_NO_KEYRING to be documented.

  • README, existing "Personal access tokens" section: it presented personal access tokens as available to anyone, which is misleading for customers. The token page isn't open to every account yet, which I checked in bc3's My::AccessTokensController. I fixed this here because it's a one-sentence change on the same topic: the section now says tokens aren't available on every account and points to the OAuth login otherwise.

  • basecamp-doctor skill: one remediation bullet for the refused-store error. It tells an agent to relay the error's hint instead of looping on auth login, and never to send the user off to create a personal access token.

Deliberately not done: a silent plain-file fallback

One tempting fix is to also keep a plaintext copy of every keyring login, so a sandbox that refuses the keyring can still read it. That isn't in this PR:

  • It would put every user's refresh token on disk in plaintext to serve the minority who run inside a sandbox. That undoes the reason the keyring is the default.
  • It wouldn't reliably work. A sandbox that refuses the vault often limits filesystem access too, and Codex limits writes to the workspace. A copy it can read but not rewrite breaks at the first refresh, because the refresh token rotates.
  • Two stores holding one rotating refresh token can drift apart. One refreshes, and the other's copy becomes a replayed token that Basecamp treats as theft and signs the whole login out (see "Containers, CI and scheduled jobs").

Choosing file storage stays explicit (BASECAMP_NO_KEYRING=1), and the new README section explains when to choose it and what it costs.

Not covered

  • A keyring that is unavailable rather than refused, such as a missing D-Bus or a locked keychain with no prompt, keeps the login hint. On a host with no keyring, a login is the right remedy because it falls back to file storage and works. Only a permission refusal changes the remedy.
  • auth status and doctor still use IsAuthenticated (a bool) and report a refused store as "not logged in". That could be a follow-up.
  • No Windows CI runs these tests. The Windows classification rests on the stdlib syscall.Errno.Is mapping of ERROR_ACCESS_DENIED, and on go-keyring/wincred returning that Errno unwrapped from CredWrite. I checked both in source (go-keyring v0.2.8, wincred v1.2.3), and GOOS=windows go vet and a test build pass.

Verification

  • Wrote the new tests first and watched them fail on main:
    • TestAccessTokenWhenTheKeyringRefusesAccessNamesTheRefusal: the message lacked "refused access", and the hint was Run: basecamp auth login.
    • TestCredentialStoreRefusedHintNamesRemediesAnyoneCanTake: failed against this PR's first hint, which pointed to the personal-access-token page.
    • TestCheckAuthenticatedReportsARefusedStore: returned false, nil.
    • TestAccessTokenWithNothingStoredStillSaysLogin, the control, passes both before and after. That pins the classification to refusals only.
  • End to end on Linux through the real credstore and go-keyring chain. I pointed DBUS_SESSION_BUS_ADDRESS at a socket in a mode-000 directory, so the probe gets connect: permission denied.
    • v0.13.0: auth_required, hint Run: basecamp auth login.
    • This branch: auth_required, message "…the system credential store refused access: …permission denied…", and the hint above.
    • File-storage remedy: with the same refused keyring and XDG_CONFIG_HOME pointing at a directory holding a file-stored login, the CLI reads the file and sends the request. This worked both with and without BASECAMP_NO_KEYRING=1 on the agent's side.
  • bin/ci passes locally.

@robzolkos
robzolkos requested a review from a team as a code owner October 10, 2026 00:59
Copilot AI balanced review requested due to automatic review settings October 10, 2026 00:59
@robzolkos robzolkos self-assigned this Oct 10, 2026
@github-actions github-actions Bot added tests Tests (unit and e2e) skills Agent skills auth OAuth authentication docs labels Oct 10, 2026

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread skills/basecamp-doctor/SKILL.md Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved

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.

🟡 Changes recommended

Windows shell instructions, proxy guidance, and doctor remediation contain misleading documentation.

3 open findings
What changed in this PR

Distinguishes inaccessible credential stores from missing credentials and provides sandbox-appropriate remediation.

Changes:

  • Classifies permission-denied credential stores and propagates errors through authentication checks.
  • Adds regression tests for refused and empty stores.
  • Documents sandbox authentication alternatives and doctor guidance.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
internal/​auth/​auth.go Classifies refused credential-store access and supplies a token-oriented hint.
internal/​auth/​keyring_test.go Tests refused-store and genuinely empty-store behavior.
README.md Documents authentication options for sandboxed agents.
skills/​basecamp-doctor/​SKILL.md Adds refused-store remediation guidance.

🧠 Review effort: Balanced


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

Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread skills/basecamp-doctor/SKILL.md Resolved
Copilot AI balanced review requested due to automatic review settings October 10, 2026 01:17

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.

🔵 Needs a closer look

The documented workaround uses shell syntax that does not work for the primary Windows scenario.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 10, 2026 01:21
@robzolkos

Copy link
Copy Markdown
Collaborator Author

🤖 Review summary as of ece5e73:

  • All six inline threads (cubic and Copilot, on 7e2d864) were answered and resolved. The PowerShell form and the doctor-skill wording were fixed in ece5e73. The "avoids all of this" proxy claim was removed in 0d2ca50.
  • Copilot's review body on 0d2ca50 lists two findings: the POSIX-only command and the doctor wording. Both are fixed in ece5e73.
  • 0d2ca50 also corrects this PR's first hint. Personal access tokens aren't open to every account, so the hint, the README and the skill no longer send anyone to create one. See the PR description.

Copilot AI previously approved these changes Oct 10, 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.

🟢 Approved

The implementation, tests, and documentation consistently distinguish inaccessible credentials from missing credentials.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

Inside an AI agent's sandbox the OS can refuse the keyring outright: Codex's
Windows sandbox answers Credential Manager with "Access is denied." The
store then falls back to an empty credentials.json, and the miss surfaced as
auth_required with "Run: basecamp auth login" -- a login the person already
has, and one the sandbox would refuse in turn.

A store error that wraps fs.ErrPermission (ERROR_ACCESS_DENIED on Windows,
EACCES/EPERM on Unix) is now reported as a refusal, ahead of the
no-credential case it also matches, with a hint naming BASECAMP_TOKEN and
the personal access token page. CheckAuthenticated returns that error
rather than "nothing stored", so gates stop offering a login. An empty
store with no refusal behind it still says to log in.
Covers BASECAMP_TOKEN with a personal access token, a login made outside the
sandbox (file storage only), Basecamp's hosted MCP server, and the egress
proxy settings sandboxes tend to need. Also documents BASECAMP_NO_KEYRING,
which #800 asks for.
Personal access tokens are not issued to every account, so the refused-store
hint, the sandbox README section and the doctor skill must not send people to
mint one. The hint now names running outside the sandbox, a file-stored login
in a directory the sandbox can write (BASECAMP_NO_KEYRING=1 plus
XDG_CONFIG_HOME), and Basecamp's hosted MCP server, with BASECAMP_TOKEN only
for a token the person already holds. The Personal access tokens section says
the same about availability.
…Shell form

The refused-store classifier also covers a credentials file the OS will not
let the CLI read, where there may be no login at all, so the doctor skill
and the hint's comment no longer assert one exists. The file-storage login
gains its PowerShell form, since the motivating case is Windows.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 19:30
@robzolkos
robzolkos force-pushed the fix/keyring-refused-hint branch from ece5e73 to 208f665 Compare October 12, 2026 19:30
Copilot AI dismissed their stale review, a newer Copilot review was requested October 12, 2026 19:30
@robzolkos

Copy link
Copy Markdown
Collaborator Author

🤖 Rebased onto main to pick up the change-aware CI from #882; no code changes.

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.

🟢 Approved

The implementation, tests, documentation, and remediation guidance consistently address permission-refused credential stores.

0 open findings

🧠 Review effort: Balanced

jorgemanrubia added a commit that referenced this pull request Nov 7, 2026
…ct reads

- A save or delete that moves to the keyring after a probe timeout removes
  the key's plaintext copy, which reads after a timeout still serve first;
  a delete of a key only the file held succeeds.
- A direct-read miss of a held credential is asked again after the grace
  wait, as a store read is.
- A refusal on the direct read or the patient probe is an answer (#866):
  reported as itself, with no backoff and no retryable outage.
- One direct read at a time; others are refused at once. A caller that
  stops waiting is not held for the 60s bound.
- The connector's first credential read honors a signal delivered as its
  wait ends.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth OAuth authentication docs skills Agent skills tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants