Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSM-522 Fixed error when shortcuts present #26

Merged
Merged
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
15 changes: 13 additions & 2 deletions secretsmanager/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ func getRecord(path string, title string, client core.SecretsManager) (secret *c
return nil, fmt.Errorf("record not found - title: %s", title)
}
return secret, nil
} else {
} else { // find by UID
secrets, err := client.GetSecrets([]string{path})
if err != nil {
return nil, err
Expand All @@ -717,7 +717,18 @@ func getRecord(path string, title string, client core.SecretsManager) (secret *c
return nil, fmt.Errorf("record not found - UID: %s", path)
}
if len(secrets) > 1 {
return nil, fmt.Errorf("expected 1 record - found %d records for UID: %s", len(secrets), path)
// linked records a.k.a. shortcuts:
// vault does not allow duplicate UIDs but we can get an UID multiple times
// if the record is linked across multiple shared folders all shared to the same KSM App
dupes := 0
for i := range secrets {
if secrets[0].Uid == secrets[i].Uid {
dupes++
}
}
if len(secrets) != dupes {
return nil, fmt.Errorf("expected 1 record - found %d records for UID: %s", len(secrets), path)
}
}
return secrets[0], nil
}
Expand Down
Loading