Manage Two-Factor Authentication
In this article, we explore common use cases concerning two-factor authentication feature control via TeamCity REST API. Note that these endpoints accept only authentication via access tokens.
tip
The User object has the respective boolean field
enabled2FA
.
To start setup of 2FA for the current user, use the following endpoint:
POST/app/rest/2FA/setup
The method will return a secret key, set of recovery keys and UUID for the confirmation of setup.
To confirm the setup of 2FA for the current user, use the following endpoint:
POST/app/rest/2FA/confirm?uuid=<uuid>&password=<password>
where uuid
is the UUID returned by /setup
method, and password
is 6-digit TOTP password. If supplied password matches the secret key found by UUID, 2FA setup is finished.
To remove secret key and recovery keys for a specific user, use:
DELETE/app/rest/2FA/<userLocator>/disable
Here, userLocator
is typed as UserLocator. For example, to disable 2FA for john.doe
username, send:
DELETE/app/rest/2FA/username:john.doe/disable
To generate a new set of recovery keys for the current user, use:
POST/app/rest/2FA/newRecoveryKeys
The format of recovery keys is [0-9a-f]{6}-[0-9a-f]{6}
. Old recovery keys will be discarded.
To refresh grace period (a period when user can sign in without enabled 2FA) for a specific user, use the following endpoint:
POST/app/rest/2FA/<userLocator>/refreshGracePeriod
Grace period length is managed by the teamcity.auth.2fa.grace.period
property; the default value is 1 week.
Thanks for your feedback!