cli: option to disable encryption of keychain matter

* option to disable encryption of keys

Avoids issue of token invalidation when switching machines with a shared home directory, as suggested by @connor4312 in https://github.com/microsoft/vscode-remote-release/issues/8110#issuecomment-1452270922

Fixes #8110

* Update cli/src/auth.rs

Co-authored-by: Connor Peet <connor@peet.io>

* Change variable to VSCODE_CLI_DISABLE_KEYCHAIN_ENCRYPT

Co-authored-by: Connor Peet <connor@peet.io>

---------

Co-authored-by: Connor Peet <connor@peet.io>
This commit is contained in:
Simon Byrne 2023-03-02 11:28:57 -08:00 committed by GitHub
parent b0b73ee333
commit ef46983a3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -183,6 +183,9 @@ where
T: Serialize + ?Sized,
{
let dec = serde_json::to_string(value).expect("expected to serialize");
if std::env::var("VSCODE_CLI_DISABLE_KEYCHAIN_ENCRYPT").is_ok() {
return dec;
}
encrypt(&dec)
}
@ -191,7 +194,7 @@ fn unseal<T>(value: &str) -> Option<T>
where
T: DeserializeOwned,
{
// small back-compat for old unencrypted values
// small back-compat for old unencrypted values, or if VSCODE_CLI_DISABLE_KEYCHAIN_ENCRYPT set
if let Ok(v) = serde_json::from_str::<T>(value) {
return Some(v);
}