99designs / keyring

Go library providing a uniform interface across a range of secure credential stores
MIT License
580 stars 138 forks source link

How to use the default keyring using SecretServiceBackend? #134

Open benma opened 10 months ago

benma commented 10 months ago

Whatever I use for LibSecretCollectionName or ServiceName, the library attempts to create a new keyring. How can I use the default keyring? In seahorse it is listed as Default keyring:

Even if I name the collection the same way, the library will create a new keyring with the same name:

package main

import (
    "github.com/99designs/keyring"
)

func main() {
    ring, err := keyring.Open(keyring.Config{
        AllowedBackends: []keyring.BackendType{
            keyring.SecretServiceBackend,
        },
        LibSecretCollectionName: "Default keyring",
        ServiceName:             "myapp",
    })
    if err != nil {
        panic(err)
    }

    err = ring.Set(keyring.Item{
        Key:  "foo",
        Data: []byte("secret-bar"),
    })
    if err != nil {
        panic(err)
    }
}

With the https://github.com/zalando/go-keyring library, using their example from the README will write to the default keyring, so it should be possible somehow.

tylercreller commented 9 months ago

@benma I was able to work around this by not including a space in my LibSecretCollectionName.