Skip to content

Support 2FAΒ #68

@lneely

Description

@lneely

2FA support in pcloudcc is incomplete to nonexistent. Implement.

From code documentation:

/* Upon seein a status of PSTATUS_TFA_REQUIRED the application is supposed to
 * let the user know that two factor authentication is enabled and provide the
 * user with three choices 1) get code by SMS. After that the application calls
 * psync_tfa_send_sms(), possibly display the returned phone number, wait for
 * code input and call psync_tfa_set_code(code, trusted, 0) 2) get code by
 * notification at any other logged in device. Application calls
 * psync_tfa_send_nofification(), possibly display logged devices list, wait for
 * code input and call psync_tfa_set_code(code, trusted, 0) 3) use recovery
 * code, in this case the user provides the recovery code and application calls
 * psync_tfa_set_code(code, trusted, 1)
 *
 * psync_tfa_has_devices() - can be called after PSTATUS_TFA_REQUIRED is
 * received and returns true if the user has other devices logged in
 *
 * psync_tfa_type() - can be called after PSTATUS_TFA_REQUIRED is received and
 * returns TFA type. 1 - msisdn 2 - google authenticator
 *
 * psync_tfa_send_sms() - sends SMS with two factor authentication code to the
 * phone number on file. If parameters country_code and phone_number are not
 * NULL, those are filled with user's phone number (split in two parts). In this
 * case the caller needs to free the returned values. Returns -1 in case of
 * network error or one of the positive error codes listed at
 * https://docsqa2.pcloud.com/methods/auth/tfa_sendcodeviasms.html
 *
 * psync_tfa_send_nofification() - sends notification with two factor
 * authentication code to all already logged in devices. If devices_list is not
 * null it is filled in with list of user's devices. In this case the caller is
 * supposed to free the list with a single call to psync_free(). Returns -1 in
 * case of network error or one of the positive error codes listed at
 * https://docsqa2.pcloud.com/methods/auth/tfa_sendcodeviasysnotification.html
 *
 * psync_tfa_set_code() - sets the two factor code that is to be used for
 * logging in. If "trusted" is set, this device will be marked trusted and will
 * not require two factor authentication in the future. The "is_recovery"
 * parameter is supposed to be set if a recovery code is used and be zero in
 * case of SMS or notification code. Note that the function is void. Bad code
 * will be signalled with status change to PSTATUS_BAD_LOGIN_DATA. In that case
 * the login procedure can either be retried from the beggining or from
 * sending/providing two factor authentication code.
 *
 */

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions