Skip to content

Commit 0645423

Browse files
authored
Merge pull request #471 from talktosam2003/endpoint
setup endpoint
2 parents 638000a + f82c066 commit 0645423

13 files changed

Lines changed: 749 additions & 8 deletions

File tree

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ FRONTEND_URL=http://localhost:5173
1515
# JWT signing secret (required, min 32 characters)
1616
JWT_SECRET=replace-this-with-a-strong-32-char-minimum-jwt-secret
1717

18+
# TOTP 2FA encryption key — 64 hex characters (32 bytes, AES-256).
19+
# Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
20+
# Optional in development (falls back to JWT_SECRET hash); required in production.
21+
TOTP_ENCRYPTION_KEY=
22+
1823
# Pino log level (optional; not validated in env.ts) — debug|info|warn|error
1924
LOG_LEVEL=debug
2025

docs/swagger.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,50 @@ paths:
16121612
application/json:
16131613
schema:
16141614
$ref: '#/components/schemas/ErrorResponse'
1615+
/api/auth/2fa/setup:
1616+
post:
1617+
summary: Initiate TOTP 2FA setup
1618+
description: >-
1619+
Generates a new TOTP secret for the authenticated user, encrypts it at
1620+
rest (AES-256-GCM), and returns an `otpauth://` URI rendered as a base64
1621+
PNG QR code data URL. The user should scan this with an authenticator app
1622+
(e.g. Google Authenticator, Authy). **2FA is not yet enabled** after this
1623+
call — the user must verify a valid TOTP code via the upcoming verify
1624+
endpoint to activate protection.
1625+
tags:
1626+
- Auth
1627+
security:
1628+
- bearerAuth: []
1629+
responses:
1630+
'200':
1631+
description: QR code data URL generated successfully
1632+
content:
1633+
application/json:
1634+
schema:
1635+
type: object
1636+
properties:
1637+
success:
1638+
type: boolean
1639+
example: true
1640+
message:
1641+
type: string
1642+
example: '2FA setup initiated. Scan the QR code with your authenticator app.'
1643+
data:
1644+
type: object
1645+
properties:
1646+
qrCodeUrl:
1647+
type: string
1648+
description: >-
1649+
Base64 PNG data URL (`data:image/png;base64,...`) to
1650+
be displayed as a QR code for the user to scan.
1651+
example: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...'
1652+
'401':
1653+
description: Missing or invalid auth token
1654+
content:
1655+
application/json:
1656+
schema:
1657+
$ref: '#/components/schemas/ErrorResponse'
1658+
16151659
/api/auth/forgot-password:
16161660
post:
16171661
summary: Request a password reset email

0 commit comments

Comments
 (0)