Skip to content

Conversation

@timabrmsn
Copy link
Contributor

Implements support for MFA accounts.

When a profile for an MFA user is created, the user will see the message:

Multi-factor account detected. `--totp <token>` option will be required for all code42 invocations.

Then any commands that initialize the sdk will either require the --totp <token> option, or if the option isn't provided, the CLI will prompt for the token.

@github-actions
Copy link

github-actions bot commented Apr 29, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️

@alanag13
Copy link
Contributor

Can/does that message also get printed when the user switches to that account using profile use?

@timabrmsn
Copy link
Contributor Author

Can/does that message also get printed when the user switches to that account using profile use?

It does not, as it only knows the user requires MFA when we validate the password. So I guess it also doesn't print if the user doesn't supply a password when creating the profile.

@alanag13
Copy link
Contributor

Maybe we could validate upon switching too? Might be nice to know if your credentials are no longer good when you switch anyway.


If you choose not to store your password in the CLI, you must enter it for each command that requires a connection.

The Code42 CLI supports local accounts with MFA (multi-factor authentication) enabled. The Time-based One-Time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to be able to login only once. We have a story for this, right? For storing the token and only prompting when it expires

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tokens only last like 20 seconds, so it's not really going to help too much to store it. Or do you mean store the key that is used to generate the tokens in authenticator apps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, you mean the v3 token?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I meant the v3 token

c42profile.authority_url, c42profile.username, password, None
)
except Py42MFARequiredError:
echo(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we prompt at this point so that we can still validate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need to validate? If we get the Py42MFARequired error, it means the password was correct but the token was missing.

except Py42UnauthorizedError as err:
logger.log_error(str(err))
raise Code42CLIError("Invalid credentials for user {}".format(username))
if "INVALID_TIME_BASED_ONE_TIME_PASSWORD" in err.response.text:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now but this seems like a common enough scenario that we should have a custom py42 error for this

@timabrmsn timabrmsn merged commit 95195df into master May 18, 2021
@github-actions github-actions bot locked and limited conversation to collaborators May 18, 2021
@timabrmsn timabrmsn deleted the feature/2fa branch August 27, 2021 18:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants