Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use InMemoryAccountInfo when using env vars for authentication #1009

Merged

Conversation

agoncharov-reef
Copy link
Contributor

@agoncharov-reef agoncharov-reef commented Mar 27, 2024

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 and InMemoryCache for caching data.

Exception: when user calls authorize-account or clear-account commands, they store (or clear) credentials on disk even if "env vars authorization" is used.

--

This PR also removes b2_api parameter from ConsoleTool class init method. It was used only in tests and allowed passing mocked B2Api 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 to B2Api during initialization, but ConsoleTool received already initialized mocked B2Api instance and thus those parameters couldn't be applied.

This is fixed by delegating B2Api initialization to ConsoleTool entirely, and for tests we use monkeypatching which substitutes few functions used to initialize B2Api inside ConsoleTool.

@mjurbanski-reef mjurbanski-reef merged commit d9d8851 into Backblaze:master Mar 28, 2024
30 checks passed
@mjurbanski-reef mjurbanski-reef deleted the inmemory-if-env-vars-auth branch March 28, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants