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

Enhancements to Secret Management #364

Merged
merged 58 commits into from Sep 12, 2023
Merged

Enhancements to Secret Management #364

merged 58 commits into from Sep 12, 2023

Conversation

maxjeblick
Copy link
Contributor

This pull request adds different backend handlers for storing passwords with keyring being the default.
On systems where keyring fails, it is possible to select a local .env backend, or not to save the tokens at all.

Purpose
The purpose of these changes is to provide the application with greater flexibility and security when it comes to managing and storing sensitive information.

Backward compatibility
A migration process is implemented that converts the old pickle format.
On systems where migration to keyring fails, the user needs to manually reenter missing tokens (this is mentioned in the logs).

Fixes #363

@fatihozturkh2o
Copy link
Contributor

fatihozturkh2o commented Aug 16, 2023

2023-08-16 03:36:58,099 - INFO: Could not migrate tokens. Please delete /home/fatih/h2o-llmstudio/data/dbs/anon.settings and set your credentials again.Error:

This warning is expected, see the code for migration. It basically means that keyring storage fails (as it is the case on our remote machines, I wasn't able to configure keyring). The old settings are not deleted in this case.

I'm also happy for suggestions how to better handle this, e.g. using a pop-up that informs the user.

The other warnings ... are not in the config are unrelated to the PR.

I see. So the warnings are from the main branch?

@maxjeblick
Copy link
Contributor Author

I see. So the warnings are from the main branch?

Yes, they arise when calling load_config_yaml. Probably better to make the warning more explicit.

@fatihozturkh2o
Copy link
Contributor

I see. So the warnings are from the main branch?

Yes, they arise when calling load_config_yaml. Probably better to make the warning more explicit.

they seem to be spamming the logs though. Here I just clicked Home while running my experiment:

image

@maxjeblick
Copy link
Contributor Author

Created an issue for tracking: #372

Copy link
Contributor

@fatihozturkh2o fatihozturkh2o left a comment

Choose a reason for hiding this comment

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

lgtm!

(you might consider adding type annotation for what the following two functions return though: _get_secrets_handler, _get_usersettings_path)

Copy link
Collaborator

@pascal-pfeiffer pascal-pfeiffer left a comment

Choose a reason for hiding this comment

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

Thank you for this security related upgrade, @maxjeblick

I still ran into issues when just upgrading to the PR branch, but using a clean environment everything was working fine. I think we can live with that.

lgtm

@maxjeblick
Copy link
Contributor Author

Sorry for the late reply @pascal-pfeiffer, I ran into some new timeout issues after I tried to configure keyring on the remote machine. Compared to the reviewed PR, I added the following:

  • Default credential_saver was changed to .env file to avoid any keyring issues. This should allow for migration without issues.
  • Keyring handler will be disabled if it is not configured correctly (keyring.get_password fails for some reason). While this adds up to 3 seconds time overhead when starting the app, it will safeguard against potential hang-ups.
  • I fixed merge conflicts with latest main

Please feel free to re-review the changes.

@maxjeblick maxjeblick merged commit 31d6331 into main Sep 12, 2023
5 checks passed
@maxjeblick maxjeblick deleted the max/use_keyring_storage branch September 12, 2023 11:06
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.

[CODE IMPROVEMENT] Add option to save secrets in Keyring
3 participants