Skip to content

feat(cli): bgagent change-password command + force-rotate on first login #238

Description

@isadeks

Problem

The current admin onboarding flow (bgagent admin invite-user <email>) creates a Cognito user with a permanent password that the admin generates and shares with the teammate via Slack/email. Two UX gaps fall out of that:

  1. No way for a teammate to rotate their password. They keep using the admin-generated string forever unless they go through Cognito's console manually. The CLI has no bgagent change-password command.
  2. The admin's terminal scrollback / Slack message stays canonical. The shared password is the actual login credential indefinitely. Standard secure pattern is a temporary admin-generated password that the teammate must replace on first login — that one-line message stops being a credential after the teammate logs in once.

Acceptance criteria

Part 1 — change-password command

  • New bgagent change-password command. Interactive: prompts for current password + new password (twice for confirmation).
  • Calls Cognito's ChangePasswordCommand against the user's current session token.
  • Cognito enforces password policy server-side and returns a structured error; surface it cleanly.
  • Works for any user with a valid bgagent login session.
  • Tests: success, wrong current password, weak new password, no session.

Part 2 — force-rotate on first login

  • Flip bgagent admin invite-user to set a temporary password (drop the Permanent: true on AdminSetUserPassword).
  • Handle the NEW_PASSWORD_REQUIRED challenge in bgagent login: when Cognito returns it, prompt the teammate for a new password, call RespondToAuthChallenge, persist the resulting tokens.
  • Update LINEAR_SETUP_GUIDE.md and USER_GUIDE.md teammate-onboarding sections to reflect the new flow ("you'll be prompted to set a permanent password on first login").

Out of scope (future)

  • Forgot-password (ForgotPassword + ConfirmForgotPassword) — needs Cognito email delivery, which means SES wiring. Park as a separate followup.
  • MFA enrollment.
  • Admin-side password rotation (admin reset-password <email>) — distinct from a user changing their own password.

Files

  • cli/src/commands/change-password.ts (new)
  • cli/src/commands/admin.ts — drop Permanent: true
  • cli/src/auth.ts — handle NEW_PASSWORD_REQUIRED challenge in login
  • cli/src/bin/bgagent.ts — register change-password
  • cli/test/commands/change-password.test.ts (new)
  • cli/test/commands/admin.test.ts — update for temp password
  • cli/test/auth.test.ts — challenge-flow coverage
  • docs/guides/LINEAR_SETUP_GUIDE.md + docs/guides/USER_GUIDE.md — teammate-flow updates
  • Mirrors regenerated via docs/scripts/sync-starlight.mjs

Verification

  • bgagent change-password rotates an existing user's password end-to-end.
  • New admin invite-user flow: admin runs invite → teammate receives bundle + temp password → first bgagent login prompts them to set a permanent password → second bgagent login succeeds with the new password.

Activity

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

Metadata

Metadata

Labels

approvedWhen an issue has been approved and readyclibgagent CLI commands and HTTP clientenhancementNew feature or requestsecurityCedar/HITL, IAM least-privilege, secrets, PII/DLP, guardrails, supply-chain/CVE

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions