Add slug login browser flow #60

Merged
erik merged 1 commit from feat/task-b8374859-slug-login-flow into main 2026-05-22 15:23:51 -05:00
Owner

Summary

  • Add protected /cli/auth browser route that redirects anonymous users through login and generates a one-time-display API key for authenticated sessions.
  • Add protected /api/v1/auth/check API key verification endpoint and OpenAPI coverage.
  • Add slug login [api-base-url] to open/print the browser auth URL, prompt for a pasted API key, verify it, and save redacted config.
  • Preserve login redirect return paths and document the new CLI login flow.

Testing

  • make check
  • ./scripts/pre-pr.sh

Task: #task-b8374859

## Summary - Add protected `/cli/auth` browser route that redirects anonymous users through login and generates a one-time-display API key for authenticated sessions. - Add protected `/api/v1/auth/check` API key verification endpoint and OpenAPI coverage. - Add `slug login [api-base-url]` to open/print the browser auth URL, prompt for a pasted API key, verify it, and save redacted config. - Preserve login redirect return paths and document the new CLI login flow. ## Testing - `make check` - `./scripts/pre-pr.sh` Task: #task-b8374859
feat: add slug login browser flow
All checks were successful
CI / build-lint-test (pull_request) Successful in 25s
94fdf055ea
Task: #task-b8374859
erik force-pushed feat/task-b8374859-slug-login-flow from 94fdf055ea
All checks were successful
CI / build-lint-test (pull_request) Successful in 25s
to 846b4ae941
All checks were successful
CI / build-lint-test (pull_request) Successful in 29s
2026-05-22 14:15:49 -05:00
Compare
Author
Owner

PR Review: Approved

Summary

Reviewed PR #60 at commit 846b4ae. The PR adds the browser-assisted CLI login flow: /cli/auth redirects anonymous users through admin login and generates a raw API key for authenticated sessions, /api/v1/auth/check verifies bearer API keys, and slug login [api-base-url] opens/prints the browser auth URL, prompts for the pasted key, verifies it, and saves local config without printing the key.

Acceptance Criteria

  • slug login opens or prints the browser auth URL.
  • /cli/auth requires an authenticated admin session before generating an API key.
  • Unauthenticated /cli/auth redirects through login and returns after successful magic-link verification.
  • Authenticated /cli/auth creates an API key and displays the raw key once.
  • CLI verifies the pasted API key before saving config.
  • Saved CLI config redacts API key output in existing config display commands.
  • Tests cover login URL derivation, missing config/prompt behavior, key verification failure, key verification success, API key redaction, route auth/redirect behavior, and API auth-check behavior.
  • Relevant lint/test checks pass — make check, ./scripts/pre-pr.sh, and Forgejo CI passed.

Blocking Issues

None.

Warnings

None.

Verdict

Approved for merge.

## PR Review: Approved ### Summary Reviewed PR #60 at commit `846b4ae`. The PR adds the browser-assisted CLI login flow: `/cli/auth` redirects anonymous users through admin login and generates a raw API key for authenticated sessions, `/api/v1/auth/check` verifies bearer API keys, and `slug login [api-base-url]` opens/prints the browser auth URL, prompts for the pasted key, verifies it, and saves local config without printing the key. ### Acceptance Criteria - [x] `slug login` opens or prints the browser auth URL. - [x] `/cli/auth` requires an authenticated admin session before generating an API key. - [x] Unauthenticated `/cli/auth` redirects through login and returns after successful magic-link verification. - [x] Authenticated `/cli/auth` creates an API key and displays the raw key once. - [x] CLI verifies the pasted API key before saving config. - [x] Saved CLI config redacts API key output in existing config display commands. - [x] Tests cover login URL derivation, missing config/prompt behavior, key verification failure, key verification success, API key redaction, route auth/redirect behavior, and API auth-check behavior. - [x] Relevant lint/test checks pass — `make check`, `./scripts/pre-pr.sh`, and Forgejo CI passed. ### Blocking Issues None. ### Warnings None. ### Verdict Approved for merge.
erik force-pushed feat/task-b8374859-slug-login-flow from 846b4ae941
All checks were successful
CI / build-lint-test (pull_request) Successful in 29s
to 26da9bb69a
All checks were successful
CI / build-lint-test (pull_request) Successful in 24s
2026-05-22 14:30:23 -05:00
Compare
Author
Owner

PR Review Update: Approved

Reviewed updated PR #60 at commit 26da9bb after the first-run UX patch.

Update verified

  • slug login now works without a manually supplied URL when a local dev server is reachable at http://localhost:3000/api/v1.
  • The CLI now prints the selected API base URL before opening/printing /cli/auth, so the source is visible.
  • Explicit URLs and existing saved config still take precedence over the local-dev default.
  • If local dev is unavailable and no config exists, the CLI falls back to prompting for the API base URL.
  • Added tests for local-dev default selection and fallback prompting.

Checks

  • make check passed locally.
  • ./scripts/pre-pr.sh passed locally.
  • Forgejo CI passed for commit 26da9bb.

Verdict

Approved for merge.

## PR Review Update: Approved Reviewed updated PR #60 at commit `26da9bb` after the first-run UX patch. ### Update verified - `slug login` now works without a manually supplied URL when a local dev server is reachable at `http://localhost:3000/api/v1`. - The CLI now prints the selected API base URL before opening/printing `/cli/auth`, so the source is visible. - Explicit URLs and existing saved config still take precedence over the local-dev default. - If local dev is unavailable and no config exists, the CLI falls back to prompting for the API base URL. - Added tests for local-dev default selection and fallback prompting. ### Checks - `make check` passed locally. - `./scripts/pre-pr.sh` passed locally. - Forgejo CI passed for commit `26da9bb`. ### Verdict Approved for merge.
erik force-pushed feat/task-b8374859-slug-login-flow from 26da9bb69a
All checks were successful
CI / build-lint-test (pull_request) Successful in 24s
to ac9e167c38
All checks were successful
CI / build-lint-test (pull_request) Successful in 29s
2026-05-22 15:06:47 -05:00
Compare
Author
Owner

PR Review Update: Approved

Reviewed updated PR #60 at commit ac9e167 after the CLI config UX changes.

Update verified

  • CLI config now defaults to YAML at ${XDG_CONFIG_HOME:-~/.config}/slug/config.yaml.
  • Config is now a simple single-site shape: apiBaseUrl, apiKey, and optional apiKeyReference; no profiles.
  • Added global --config <file> support, e.g. slug --config ./dev.slug.yaml login.
  • slug login uses the configured apiBaseUrl; no URL argument is required for normal use.
  • slug config show continues to redact the raw API key.
  • Tests cover YAML read/write and explicit --config file usage.

Checks

  • make check passed locally.
  • ./scripts/pre-pr.sh passed locally.
  • Forgejo CI passed for commit ac9e167.

Verdict

Approved for merge.

## PR Review Update: Approved Reviewed updated PR #60 at commit `ac9e167` after the CLI config UX changes. ### Update verified - CLI config now defaults to YAML at `${XDG_CONFIG_HOME:-~/.config}/slug/config.yaml`. - Config is now a simple single-site shape: `apiBaseUrl`, `apiKey`, and optional `apiKeyReference`; no profiles. - Added global `--config <file>` support, e.g. `slug --config ./dev.slug.yaml login`. - `slug login` uses the configured `apiBaseUrl`; no URL argument is required for normal use. - `slug config show` continues to redact the raw API key. - Tests cover YAML read/write and explicit `--config` file usage. ### Checks - `make check` passed locally. - `./scripts/pre-pr.sh` passed locally. - Forgejo CI passed for commit `ac9e167`. ### Verdict Approved for merge.
erik force-pushed feat/task-b8374859-slug-login-flow from ac9e167c38
All checks were successful
CI / build-lint-test (pull_request) Successful in 29s
to 763b3ba600
All checks were successful
CI / build-lint-test (pull_request) Successful in 29s
2026-05-22 15:15:22 -05:00
Compare
Author
Owner

PR Review Update: Approved

Reviewed updated PR #60 at commit 763b3ba after adding Makefile dev CLI support.

Update verified

  • Added make dev-config to write ignored local CLI config at ./.slug/dev.yaml.
  • Added make slug ARGS="..." to build and run the slug CLI with that dev config.
  • .slug/ is ignored so generated dev config is not committed.
  • make dev-config writes the machine IP API URL, e.g. apiBaseUrl: http://<machine-ip>:3000/api/v1.

Checks

  • make dev-config passed locally.
  • make check passed locally.
  • ./scripts/pre-pr.sh passed locally.
  • Forgejo CI passed for commit 763b3ba.

Verdict

Approved for merge.

## PR Review Update: Approved Reviewed updated PR #60 at commit `763b3ba` after adding Makefile dev CLI support. ### Update verified - Added `make dev-config` to write ignored local CLI config at `./.slug/dev.yaml`. - Added `make slug ARGS="..."` to build and run the `slug` CLI with that dev config. - `.slug/` is ignored so generated dev config is not committed. - `make dev-config` writes the machine IP API URL, e.g. `apiBaseUrl: http://<machine-ip>:3000/api/v1`. ### Checks - `make dev-config` passed locally. - `make check` passed locally. - `./scripts/pre-pr.sh` passed locally. - Forgejo CI passed for commit `763b3ba`. ### Verdict Approved for merge.
erik force-pushed feat/task-b8374859-slug-login-flow from 763b3ba600
All checks were successful
CI / build-lint-test (pull_request) Successful in 29s
to f280ae961e
All checks were successful
CI / build-lint-test (pull_request) Successful in 28s
2026-05-22 15:18:15 -05:00
Compare
erik merged commit 06d5d4dddf into main 2026-05-22 15:23:51 -05:00
erik deleted branch feat/task-b8374859-slug-login-flow 2026-05-22 15:23:52 -05:00
Sign in to join this conversation.
No description provided.