Skip to content

Commit ad9ffed

Browse files
author
Jayden Thorup
committed
Prefer SDK-decrypted vault names over manual config mapping
- With SDK v0.4.1-beta.1+, vault names are decrypted after biometric auth - Manual vault name mapping now only used as fallback for [Encrypted] names - Makes manual config.yaml vault mapping optional for SDK users - Improves UX: users see real vault names without manual configuration
1 parent 7404063 commit ad9ffed

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

internal/secrets/onepassword_sdk.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type OnePasswordSDKProvider struct {
1818
accountName string
1919
enabled bool
2020
vaults []VaultInfo // Stores vault ID and title (title may be [Encrypted] until auth)
21-
vaultNameMap map[string]string // Maps vault IDs to friendly names from config
21+
vaultNameMap map[string]string // Fallback mapping for encrypted vault names (SDK v0.4.1+ decrypts automatically)
2222
cliProvider *OnePasswordProvider // Fallback to CLI if SDK not available
2323
}
2424

@@ -498,33 +498,36 @@ func (p *OnePasswordSDKProvider) ListVaults() ([]string, error) {
498498
}
499499

500500
// GetVaults returns vault information (ID and title)
501-
// Note: Titles may be [Encrypted] until biometric authentication occurs
502-
// If vault name mappings are configured, they will be used instead of encrypted titles
501+
// With SDK v0.4.1-beta.1+: Vault names are decrypted after biometric authentication
502+
// Manual vault name mappings are used only as fallback for encrypted names
503503
func (p *OnePasswordSDKProvider) GetVaults() []VaultInfo {
504504
if !p.enabled {
505505
return []VaultInfo{}
506506
}
507507

508-
// If we have vault name mappings, use them to provide friendly names
509-
if len(p.vaultNameMap) > 0 {
510-
vaults := make([]VaultInfo, 0, len(p.vaults))
511-
for _, v := range p.vaults {
512-
title := v.Title
508+
// Prefer SDK-provided decrypted names, use manual mapping only for encrypted names
509+
vaults := make([]VaultInfo, 0, len(p.vaults))
510+
for _, v := range p.vaults {
511+
title := v.Title
512+
513+
// If vault name is still encrypted, try to use manual mapping
514+
if title == "[Encrypted]" && len(p.vaultNameMap) > 0 {
513515
if friendlyName, ok := p.vaultNameMap[v.ID]; ok {
514516
title = friendlyName
515517
}
516-
vaults = append(vaults, VaultInfo{
517-
ID: v.ID,
518-
Title: title,
519-
})
520518
}
521-
return vaults
522-
}
523519

524-
return p.vaults
520+
vaults = append(vaults, VaultInfo{
521+
ID: v.ID,
522+
Title: title,
523+
})
524+
}
525+
return vaults
525526
}
526527

527528
// SetVaultNameMap sets the vault ID to friendly name mapping from config
529+
// Note: With SDK v0.4.1-beta.1+, manual mapping is only needed as fallback for encrypted names
530+
// The SDK now provides decrypted vault names after biometric authentication
528531
func (p *OnePasswordSDKProvider) SetVaultNameMap(nameMap map[string]string) {
529532
p.vaultNameMap = nameMap
530533
}

0 commit comments

Comments
 (0)