Перейти до вмісту
NimbusNexus

Двофакторна автентифікація

Двофакторна автентифікація додає другий фактор (код TOTP із застосунку-автентифікатора) до входу за паролем. Ендпоінти тут вмикають її, показують її стан і вимикають:

  • GET /api/v1/2fa/credential — генерує секрет TOTP і повертає його QR-код як зображення. Сам секрет надходить у заголовку відповіді X-Secret-Key.
  • POST /api/v1/2fa/totp_passcode_validation — надішліть цей секрет як secretKey разом із поточним шестизначним passcode із застосунку. Якщо код збігається, 2FA вмикається.
  • GET /api/v1/2fa/status — two_factor_enabled показує, чи ввімкнено 2FA.
  • POST /api/v1/2fa/off — вимикає 2FA.

Кожен користувач має один секрет TOTP; повторне підключення його замінює.

Користувачі дашборду налаштовують 2FA у браузері на сторінці налаштувань акаунта. Через API кожен виклик читає чи змінює лише власну 2FA того, хто ввійшов і здійснює виклик, і ніколи — чужу. Тим, хто викликає API з API-ключем, 2FA не потрібна — ключі самі є фактором «те, що ви маєте».

Наполегливо рекомендуємо: увімкніть 2FA для кожного акаунта людини, що має ролі в продакшн-проєктах. Більшість компрометацій акаунтів спричинені повторним використанням паролів + відсутністю другого фактора.

Що далі

Reference

GET/api/v1/2fa/credential

Two Factor Credential

Generate a TOTP secret for the calling user and return its QR-code image; the secret is delivered in a response header.

Responses

  • 200Successful Response
  • 401Unauthorized
  • 403Forbidden
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X GET "https://api.nimbusnexus.net/api/v1/2fa/credential" \
  -H "Authorization: Bearer $NIMBUS_KEY"
POST/api/v1/2fa/off

Two Factor Off

Disable two-factor authentication for the calling user.

Responses

  • 200Successful Response
  • 401Unauthorized
  • 403Forbidden
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X POST "https://api.nimbusnexus.net/api/v1/2fa/off" \
  -H "Authorization: Bearer $NIMBUS_KEY"
GET/api/v1/2fa/status

Two Factor Status

Report whether two-factor authentication is currently enabled for the calling user.

Responses

  • 200Successful Response
  • 401Unauthorized
  • 403Forbidden
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X GET "https://api.nimbusnexus.net/api/v1/2fa/status" \
  -H "Authorization: Bearer $NIMBUS_KEY"
POST/api/v1/2fa/totp_passcode_validation

Totp Passcode Validation

Validate a TOTP passcode against the supplied secret and enable two-factor authentication on success.

Request body

FieldTypeDescription
passcode*string—
secretKey*string—

Responses

  • 200Successful Response
  • 400Bad Request
  • 401Unauthorized
  • 403Forbidden
  • 422Validation error
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X POST "https://api.nimbusnexus.net/api/v1/2fa/totp_passcode_validation" \
  -H "Authorization: Bearer $NIMBUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "passcode": "example",
    "secretKey": "example"
  }'

Need to make a real call? Try these endpoints in the live Swagger UI →