Use InMemoryAccountInfo
when using env vars for authentication
#1009
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Re #894
Current behavior:
When users use env vars for authenticating in B2, those credentials are stored in
~/.b2_account_info
file which is unexpected by users and exposes B2 secrets to everyone who can read the file.New behavior (CLI >=v4 only):
If user uses env vars for authentication, console tool uses
InMemoryAccountInfo
for storing account info andInMemoryCache
for caching data.Exception: when user calls
authorize-account
orclear-account
commands, they store (or clear) credentials on disk even if "env vars authorization" is used.--
This PR also removes
b2_api
parameter fromConsoleTool
class init method. It was used only in tests and allowed passing mockedB2Api
instance, however it added complexity to production code in case when special parameters were passed (like--max_download_streams_per_file
): those parameters should be passed toB2Api
during initialization, butConsoleTool
received already initialized mockedB2Api
instance and thus those parameters couldn't be applied.This is fixed by delegating
B2Api
initialization toConsoleTool
entirely, and for tests we use monkeypatching which substitutes few functions used to initializeB2Api
insideConsoleTool
.