Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
take over change in datastrucure to login (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
blacs30 authored Aug 31, 2023
1 parent b43c3fe commit 6d957d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ func decodeBitwardenDataJson(byteData []byte) (BwData, error) {
if newBwData.ActiveUserId != "" && newBwData.UserId == "" {
// version 1.21.1 and newer
newBwData.UserId = newBwData.ActiveUserId
if val, ok := table[fmt.Sprintf("__PROTECTED__%s_masterkey_auto", newBwData.UserId)]; ok {

if val, ok := table[fmt.Sprintf("__PROTECTED__%s_user_auto", newBwData.UserId)]; ok {
newBwData.ProtectedKey = fmt.Sprintf("%s", val)
}
if val, ok := table["global"]; ok {
Expand All @@ -129,6 +130,11 @@ func decodeBitwardenDataJson(byteData []byte) (BwData, error) {
newBwData.EncKey = newBwData.Keys.CryptoSymmetricKey.Encrypted
}
}
// For Version >= 2023.8.2
if masterKeyEncryptedUserKeyVal, ok := keyVal.(map[string]interface{})["masterKeyEncryptedUserKey"]; ok {
newBwData.Keys.CryptoSymmetricKey.Encrypted = fmt.Sprintf("%s", masterKeyEncryptedUserKeyVal)
newBwData.EncKey = newBwData.Keys.CryptoSymmetricKey.Encrypted
}
if privateKeyVal, ok := keyVal.(map[string]interface{})["privateKey"]; ok {
if val, ok := privateKeyVal.(map[string]interface{})["encrypted"]; ok {
newBwData.Keys.PrivateKey.Encrypted = fmt.Sprintf("%s", val)
Expand Down
2 changes: 1 addition & 1 deletion src/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Test_decodeBitwardenDataJson1(t *testing.T) {
{
name: "since-1.21.1",
args: args{
byteData: []byte(`{"global":{"installedVersion":"1.21.1"},"userIdBlaBlubb":{"keys":{"cryptoSymmetricKey":{"encrypted":"ThisIsCryptoSymmetricKeyEncrypted"},"privateKey":{"encrypted":"ThisIsPrivateKeyEncrypted"},"apiKeyClientSecret":"ThisIsApiKeyClientSecret","legacyEtmKey":null},"profile":{"userId":"userIdBlaBlubb","email":"[email protected]","kdfIterations":50000,"kdfType":0,"lastSync":"2022-02-28T16:58:54.900Z","everBeenUnlocked":true},"tokens":{"accessToken":"ThisIsAccessToken"}},"activeUserId":"userIdBlaBlubb","__PROTECTED__userIdBlaBlubb_masterkey_auto":"ThisIs__Protected__masterkey"}`),
byteData: []byte(`{"global":{"installedVersion":"1.21.1"},"userIdBlaBlubb":{"keys":{"masterKeyEncryptedUserKey":"ThisIsCryptoSymmetricKeyEncrypted","privateKey":{"encrypted":"ThisIsPrivateKeyEncrypted"},"apiKeyClientSecret":"ThisIsApiKeyClientSecret","legacyEtmKey":null},"profile":{"userId":"userIdBlaBlubb","email":"[email protected]","kdfIterations":50000,"kdfType":0,"lastSync":"2022-02-28T16:58:54.900Z","everBeenUnlocked":true},"tokens":{"accessToken":"ThisIsAccessToken"}},"activeUserId":"userIdBlaBlubb","__PROTECTED__userIdBlaBlubb_user_auto":"ThisIs__Protected__masterkey"}`),
},
wantErr: false,
want: BwData{
Expand Down

0 comments on commit 6d957d0

Please sign in to comment.