keyring

package module
v0.0.0-...-1661cbe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2022 License: ISC Imports: 3 Imported by: 11

README

keyring provides cross-platform keychain access

http://godoc.org/github.com/tmc/keyring

Keyring provides a common interface to keyring/keychain tools.

License: ISC

Currently implemented:

  • OSX
  • SecretService
  • gnome-keychain (via "gnome_keyring" build flag)

Contributions welcome!

Usage example:

  err := keyring.Set("libraryFoo", "jack", "sacrifice")
  password, err := keyring.Get("libraryFoo", "jack")
  fmt.Println(password)
  Output: sacrifice

Example program:

 $ go get -v github.com/tmc/keyring/keyring-example && keyring-example

Linux

Linux requirements:

SecretService provider
  • dbus
gnome-keychain provider
  • gnome-keychain headers
  • Ubuntu/Debian: libgnome-keyring-dev
  • Archlinux: libgnome-keyring

Tests on Linux:

 $ go test github.com/tmc/keyring
 $ # for gnome-keyring provider
 $ go test -tags gnome_keyring github.com/tmc/keyring

Example:

 $ # for SecretService provider
 $ go get -v github.com/tmc/keyring/keyring-example && keyring-example
 $ # for gnome-keyring provider
 $ go get -v -tags gnome_keyring github.com/tmc/keyring/keyring-example && keyring-example

Documentation

Overview

Package keyring provides a cross-platform interface to keychains for password management

Currently implemented:

  • OSX
  • SecretService
  • gnome-keychain (via "gnome_keyring" build flag)

Usage

Example usage:

err := keyring.Set("libraryFoo", "jack", "sacrifice")
password, err := keyring.Get("libraryFoo", "jack")
fmt.Println(password)
Output: sacrifice

TODO

  • Write Windows provider

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound means the requested password was not found
	ErrNotFound = errors.New("keyring: Password not found")
	// ErrNoDefault means that no default keyring provider has been found
	ErrNoDefault = errors.New("keyring: No suitable keyring provider found (check your build flags)")
)

Functions

func Get

func Get(service, username string) (string, error)

Get gets the password for a paricular Service and Username using the default keyring provider.

Example
package main

import (
	"fmt"
	"github.com/gilbertchen/keyring"
)

func main() {
	keyring.Set("keyring-test", "jack", "test password")
	pw, _ := keyring.Get("keyring-test", "jack")
	fmt.Println("pw:", pw)
	// don't ignore errors like this in your code
	
Output:

func Set

func Set(service, username, password string) error

Set sets the password for a particular Service and Username using the default keyring provider.

Types

This section is empty.

Directories

Path Synopsis
Shows example use of the keyring package
Shows example use of the keyring package

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL