Skip to content

Commit 9c7df64

Browse files
authored
Fix apikey login (dani-garcia#6922)
The API Key login needs some extra JSON return key's, same as password login. Fixes dani-garcia#6912 Signed-off-by: BlackDex <black.dex@gmail.com>
1 parent 065c1f2 commit 9c7df64

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/api/identity.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,19 @@ async fn _user_api_key_login(
633633
Value::Null
634634
};
635635

636+
let account_keys = if user.private_key.is_some() {
637+
json!({
638+
"publicKeyEncryptionKeyPair": {
639+
"wrappedPrivateKey": user.private_key,
640+
"publicKey": user.public_key,
641+
"Object": "publicKeyEncryptionKeyPair"
642+
},
643+
"Object": "privateKeys"
644+
})
645+
} else {
646+
Value::Null
647+
};
648+
636649
// Note: No refresh_token is returned. The CLI just repeats the
637650
// client_credentials login flow when the existing token expires.
638651
let result = json!({
@@ -649,6 +662,7 @@ async fn _user_api_key_login(
649662
"ResetMasterPassword": false, // TODO: according to official server seems something like: user.password_hash.is_empty(), but would need testing
650663
"ForcePasswordReset": false,
651664
"scope": AuthMethod::UserApiKey.scope(),
665+
"AccountKeys": account_keys,
652666
"UserDecryptionOptions": {
653667
"HasMasterPassword": has_master_password,
654668
"MasterPasswordUnlock": master_password_unlock,

0 commit comments

Comments
 (0)