Conghao97's picture tcftrees's picture
ProgramGen release
d086025
|
Raw History Blame Contribute Delete
1.93 kB

Keyring — Usage Documentation

Keyring provides a common interface to a range of secure credential storage services. It was originally developed as part of AWS Vault, a command line tool for securely managing AWS access from developer workstations.

Supported Backends

Usage

The short version of how to use keyring is shown below.

ring, _ := keyring.Open(keyring.Config{
  ServiceName: "example",
})

_ = ring.Set(keyring.Item{
    Key: "foo",
    Data: []byte("secret-bar"),
})

i, _ := ring.Get("foo")

fmt.Printf("%s", i.Data)

Typical flow:

  1. Open a keyring with a keyring.Config (at minimum a ServiceName).
  2. Store a secret with ring.Set(keyring.Item{Key: ..., Data: ...}) where Data is a []byte.
  3. Retrieve it with ring.Get("key"); the returned item's Data field holds the secret bytes.

For full API details, see the keyring godocs.

Module Import

The package is imported as:

github.com/99designs/keyring

Notes

  • The backend selected depends on the host operating system and available credential services; the library provides a common Open/Get/Set interface across all of them.
  • Secrets are stored and returned as raw byte slices ([]byte), so any serializable value can be stored.