Skip to content

Secure auth flow: remove password, stop emailing API keys, add key regeneration #140

Closed

Description

@neuromechanist

Problems

  1. Password is unused after signup: We collect a password during registration but login uses API keys only. The password serves no purpose post-signup.

  2. API key emailed to user (insecure): On admin approval, the API key is sent via email. Email is not a secure channel for secrets.

  3. No API key regeneration: Users cannot regenerate their API key if compromised or lost.

Proposed Changes

Phase 1: Secure API key delivery

  • Stop emailing the API key to users
  • On approval, send email notifying user they are approved with instructions to retrieve their key
  • Add POST /auth/retrieve-key endpoint: user provides email + password -> if approved, returns API key (one-time display)
  • Password is now only used for this key retrieval step

Phase 2: API key regeneration

  • Add POST /auth/regenerate-key endpoint
  • Flow: user requests regeneration -> email verification sent -> user confirms -> old key revoked, new key generated
  • CLI command: nemar auth regenerate-key that triggers the flow
  • Requires email re-verification for security

Phase 3: Consider removing password entirely

  • If key retrieval can be done via email verification link instead of password, password becomes fully unnecessary
  • Evaluate removing password from signup to simplify onboarding

Current Implementation

  • Signup: backend/src/routes/auth.ts (collects password, hashes with bcrypt)
  • Approval + email: backend/src/routes/admin.ts (generates key, emails it)
  • Email service: backend/src/services/email.ts (sends approval email with API key)
  • Login: API key only, no password check

Acceptance Criteria

  • API keys are never sent via email
  • Users can securely retrieve their API key after approval
  • Users can regenerate compromised API keys with email verification

Activity

  1. added
    enhancement
    P1
    on Feb 13, 2026
  2. added 2 commits that reference this issue on Feb 13, 2026
    4e89d06
    9d18b28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions