secret-service collection name (ServiceName) can create duplicate collections
- Lenguaje dominante
- Go
- Estrellas
- 657
- Forks
- 155
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Apologies if this is known or documented already.
I ran into a head-scratcher of an issue with the secret-service backend and I was able to resolve it by changing the collection name (`ServiceName` in keyring.Config).
Example code:
```go
package main
import (
"log"
"github.com/davecgh/go-spew/spew"
"github.com/99designs/keyring"
)
func main() {
//app := "vault-token-helper"
//app := "toy"
//app := "vault_token_helper"
app := "vault"
cfg := keyring.Config{
ServiceName: app,
KeychainTrustApplication: true,
KeychainSynchronizable: false,
// FileDir:
// LibSecretCollectionName
// PassDir
// PassCmd
// PassPrefix (our app name?)
}
kr, err := keyring.Open(cfg)
if err != nil {
log.Fatal(err)
}
i := keyring.Item{
Key: "fookey",
Data: []byte("foobartokenbaz"),
Label: "Vault - fookey",
Description: "hashicorp Vault token",
KeychainNotSynchronizable: true,
}
err = kr.Set(i)
if err != nil {
log.Fatal(err)
}
i2, err := kr.Get("fookey")
if err != nil {
log.Fatal(err)
}
spew.Dump(i2)
}
```
The issue is with the ` ServiceName: app,` provided in keyring.Config. When using names such as `vault-token-helper`, `vault_token_helper`, the library would create a new collection on every run:
(screenshot from seahorse)

When I use a shorter collection name such as `toy` or `vault` I get the expected behavior - the collection is only created once and future calls to Set() update the existing item rather than creating a new collection on every run.
It's also worth noting that if you do not pass a ServiceName in the keyring.Config the library will use the default `secret-service` collection name which also exhibits the "create new collection on every call" behavior.
At this time I'm not sure if this is a bug in 99designs/keyring, a bug in gsterjov/go-libsecret, or just some limitation of collection naming in the DBus Secret Service API, but figured I would at least document what I've found in case someone knows the answer or runs into a similar issue.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.