Skip to content

Fix --status to validate against the configured sync server - #64

Open
tobiashochguertel wants to merge 2 commits into
taskbook-sh:masterfrom
tobiashochguertel:fix/auth-config-server-url
Open

tobiashochguertel wants to merge 2 commits into
taskbook-sh:masterfrom
tobiashochguertel:fix/auth-config-server-url

Conversation

@tobiashochguertel

@tobiashochguertel tobiashochguertel commented Oct 20, 2026 •

Copy link
Copy Markdown

Problem

tb --status prints Server: from config.sync.server_url, but the session check calls ApiClient::new(&creds.server_url, ...). If the configured server changed after credentials were saved (e.g. re-registered on a different server, or the config file was edited), --status probes the stale credentials URL while displaying the configured one — the two silently disagree.

Relatedly, tb --login and tb --register always prompt for a server URL when --server is omitted, even when sync is already enabled and config.sync.server_url is set.

Fix

  • status: validate the session against config.sync.server_url (the user's intent), warn when the saved credentials were issued for a different server, and print a re-auth hint (tb --login) when the session check fails.
  • login / register: when --server is omitted and sync is already enabled, use config.sync.server_url and print Using server: … instead of prompting.
  • The flag-vs-config resolution is extracted into a configured_server_url() helper with unit tests.

Verification

  • rustfmt --check clean.
  • The patched auth.rs typechecks and its 3 new unit tests pass (flag wins over configured server, configured server used when sync enabled, no fallback when sync disabled). The local toolchain predates the dep set's edition2024 requirement, so the tests were run against stubs matching this crate's Config/Credentials/ApiClient signatures — CI covers the full build.

Happy to adjust the messaging or split this if you'd prefer a smaller change.

--status validated the session against creds.server_url instead of
config.sync.server_url, so after re-registering on a different server the
check silently probed the stale credentials URL. login/register also
re-prompted for a server URL even when sync was already enabled.

- status: validate against config.sync.server_url, warn on mismatch,
  and print a re-auth hint on failure
- login/register: fall back to the configured server URL when
  --server is omitted and sync is enabled
Copilot AI balanced review requested due to automatic review settings October 20, 2026 05:54

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.

🟡 Changes recommended

Status checks can disclose saved session credentials to a different configured server.

1 open issue
What changed in this PR

Aligns authentication commands with the configured sync server.

Changes:

  • Validates status against the configured URL, with mismatch warnings and login guidance.
  • Defaults login and registration to the configured server when sync is enabled.
  • Adds unit tests for server URL selection.
File Description
crates/​taskbook-client/​src/​auth.rs Updates server selection, status checks, messaging, and tests.

Review effort: Balanced

Comment thread crates/taskbook-client/src/auth.rs Outdated
Comment on lines +217 to +226
if creds.server_url != config.sync.server_url {
println!(
"{}",
format!(
"Warning: credentials were saved for {} (config points to {})",
creds.server_url, config.sync.server_url
)
.yellow()
);
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch — fixed in bf12160. On a server mismatch --status now prints the warning, marks the session "not checked" and exits without sending the stored token anywhere; the user is directed to tb --login. URLs are compared with the same trailing-slash normalization ApiClient::new applies (same_server_url), with unit coverage.

--status sent the saved bearer token to the configured server even when
the credentials were issued by a different one. Compare normalized URLs
and skip the authenticated request on mismatch, directing the user to
re-authenticate.

Co-Authored-By: Tobias Hochgürtel <[email protected]>
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.

2 participants