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

fix the totp fallback via bw cli #172

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/bitwarden.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ func runGetItem() {
receivedItem = decryptedString
}
if bwData.UserId == "" || isDecryptSecretFromJsonFailed || attachment != "" {
log.Println("Falling back to Bitwarden CLI to get item.")

// Run the Bitwarden CLI to get the secret
// Use it also for getting attachments
if attachment != "" {
Expand All @@ -297,8 +299,10 @@ func runGetItem() {
message := "Failed to get Bitwarden item."
args := fmt.Sprintf("%s get item %s --pretty --session %s", conf.BwExec, id, token)
if totp {
log.Println("Trying to get totp via Bitwarden cli")
args = fmt.Sprintf("%s get totp %s --session %s", conf.BwExec, id, token)
} else if attachment != "" {
log.Println("Trying to get attachment via Bitwarden cli")
args = fmt.Sprintf("%s get attachment %s --itemid %s --output %s --session %s --raw", conf.BwExec, attachment, id, conf.OutputFolder, token)
}

Expand All @@ -314,8 +318,12 @@ func runGetItem() {
return
}

receivedItem = ""
if jsonPath != "" {
if totp {
} else {
receivedItem = ""
}
if jsonPath != "" && !totp {
log.Println("Sent jsonPath is", jsonPath)
// jsonpath operation to get only required part of the item
singleString := strings.Join(result, " ")
var item interface{}
Expand Down
2 changes: 1 addition & 1 deletion workflow/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,7 @@ Caching of the secret/item names (not the secret values itself) are cached so th
<string>true</string>
</dict>
<key>version</key>
<string>3.0.0</string>
<string>3.0.1</string>
<key>webaddress</key>
<string>https://github.com/blacs30/bitwarden-alfred-workflow</string>
</dict>
Expand Down
Loading