Skip to content

feat: Add auth config file with login/status/logout commands#11

Merged
gnapse merged 3 commits intomainfrom
ernesto/auth-config-file
Feb 6, 2026
Merged

feat: Add auth config file with login/status/logout commands#11
gnapse merged 3 commits intomainfrom
ernesto/auth-config-file

Conversation

@gnapse
Copy link
Contributor

@gnapse gnapse commented Feb 6, 2026

Summary

Add interactive authentication flow with config file persistence. Users can now save credentials via bob auth login and the CLI will use them if environment variables are not set. Environment variables still take priority, maintaining full backward compatibility.

Implementation

  • Config file: ~/.config/bob-cli/config.json (JSON format with service_id and api_token)
  • Auth priority: Environment variables → Config file → Error with guidance
  • Commands: bob auth login (interactive), bob auth status (show source), bob auth logout (delete config)
  • Async auth: Made getAuthHeader() async to support config file reads
  • Test coverage: 21 new tests (8 config tests, 13 auth tests)

Design Decisions

Env vars take priority so automation/CI/CD flows remain unchanged. Config file acts as a convenient fallback for local development. Both can be in use simultaneously (e.g., env var for service ID, config file for token).

@gnapse gnapse requested a review from henningmu February 6, 2026 16:37
@gnapse gnapse self-assigned this Feb 6, 2026
@gnapse gnapse requested a review from Copilot February 6, 2026 16:37
@gnapse gnapse added the 👀 Show PR PR must be reviewed before or after merging label Feb 6, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a persisted, interactive authentication flow to the bob CLI by introducing a local config file fallback (while keeping environment variables as the highest-priority source), and wires this into API requests and new bob auth * commands.

Changes:

  • Introduces ~/.config/bob-cli/config.json read/write/delete utilities for persisted credentials.
  • Updates auth resolution to prefer env vars, otherwise fall back to config; makes getAuthHeader() async and updates API request code accordingly.
  • Adds bob auth login/status/logout CLI commands plus new unit tests for config/auth behavior.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/lib/config.ts New config persistence helpers for auth credentials.
src/lib/config.test.ts Tests for config path, read/write/delete behavior.
src/lib/auth.ts Auth resolution updated to include config fallback; getAuthHeader() becomes async; adds auth-source reporting.
src/lib/auth.test.ts Tests for env vs config precedence and auth-source detection.
src/lib/api.ts Awaits async getAuthHeader() when building request headers.
src/index.ts Registers new auth command group with commander.
src/commands/auth.ts Implements bob auth login/status/logout.
package-lock.json Updates Node engine metadata in lockfile to match package settings.

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

@gnapse gnapse merged commit 222c7ae into main Feb 6, 2026
2 checks passed
@gnapse gnapse deleted the ernesto/auth-config-file branch February 6, 2026 16:55
gnapse pushed a commit that referenced this pull request Feb 6, 2026
🤖 I have created a release *beep* *boop*
---


## [1.2.0](v1.1.2...v1.2.0)
(2026-02-06)


### Features

* Add auth config file with login/status/logout commands
([#11](#11))
([222c7ae](222c7ae))

---
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>
@henningmu
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants