passwordcache

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: MPL-2.0 Imports: 6 Imported by: 0

README

= password-cache

Cache credentials using the Linux keyring in Go

For a detailed blogpost see: https://www.davids-blog.gamba.ca/posts/caching-credentials-linux-keyring-golang/

== Library

image:https://pkg.go.dev/badge/github.com/DavidGamba/dgtools/password-cache.svg[Go Reference, link="https://pkg.go.dev/github.com/DavidGamba/dgtools/password-cache"]

Import:

[source, go]
----
import (
	passwordcache "github.com/DavidGamba/dgtools/password-cache"
)
----

Simplest use:

[source, go]
----
	data, err := passwordcache.GetAndCacheSecret("ActiveDirectoryPassword", "", uint(timeout))
	if err != nil {
		return err
	}
	fmt.Printf("%s", data)
----

Documentation

Overview

Package passwordcache provides a utility to save secrets into the linux keyring

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheSecret

func CacheSecret(name string, password []byte, timeoutSeconds uint) error

CacheSecret - Saves a secret to the User Session Keyring. It will cache the secret for a given number of seconds.

To invalidate a secret, save it with a 1 second timeout.

func GetAndCacheSecret

func GetAndCacheSecret(name, msg string, timeoutSeconds uint) ([]byte, error)

GetAndCacheSecret - Gets a secret from the User Session Keyring. If the key doesn't exist, it asks the user to enter the password value. It also saves the secret to the User Session Keyring. It will cache the secret for a given number of seconds.

To invalidate a secret, save it with a 1 second timeout. Every read will refresh the cache timeout.

func GetSecret

func GetSecret(name, msg string) ([]byte, error)

GetSecret - Gets a secret from the User Session Keyring. If the key doesn't exist, it asks the user to enter the password value.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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