uvault

package module
v0.0.0-...-aa1101f Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 License: GPL-3.0 Imports: 13 Imported by: 1

README

uvault

GoDoc Go Report Card Build Status

import "github.com/marco-ostaska/uvault"

Package uvault creates simple user vaults for credentials

Usage

type Credential
type Credential struct {
	HomeDir         string // local user home directory
	Username        string // local user name
	Hostname        string // local hostname
	File            string // credential vault file full path
	CryptedKValue   string // encrypted API password or API key value
	DecryptedKValue string // decrypted API password or API key valeu
	CryptJSON       string
	DcryptJSON      string
	B64             string `json:"b64"` // base64 mask to be used by API calls
	APIKey          string `json:"key"` // APIKey, may be used for APIkey, username, in case of basic auth
	URL             string `json:"url"` // API URL
}

Credential is an abstraction to credential vault

func (*Credential) ReadFile
func (c *Credential) ReadFile(dirVault, fileVault string) error

ReadFile reads the credential vault and unmarshal it.

func (*Credential) SetInfo
func (c *Credential) SetInfo(apiKey, keyValue, url, dirVault, fileVault string) error

SetInfo set provided information to credential vault

apiKey and keyValue are the API key and Key Value (username and password in case of Baic Auth)

func (*Credential) UserInfo
func (c *Credential) UserInfo(dirVault, fileVault string) error

UserInfo parse HomeDir, Username, Hostname and File to vault.Credential

Documentation

Overview

Package uvault creates simple user vaults for credentials

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credential

type Credential struct {
	HomeDir         string // local user home directory
	Username        string // local user name
	Hostname        string // local hostname
	File            string // credential vault file full path
	CryptedKValue   string // encrypted API password or API key value
	DecryptedKValue string // decrypted API password or API key valeu
	CryptJSON       string
	DcryptJSON      string
	B64             string `json:"b64"` // base64 mask to be used by API calls
	APIKey          string `json:"key"` // APIKey, may be used for APIkey, username, in case of basic auth
	URL             string `json:"url"` // API URL
}

Credential is an abstraction to credential vault

func (*Credential) ReadFile

func (c *Credential) ReadFile(dirVault, fileVault string) error

ReadFile reads the credential vault and unmarshal it.

Example
package main

import (
	"fmt"

	"github.com/marco-ostaska/uvault"
)

func main() {
	var vCred uvault.Credential
	if err := vCred.ReadFile("uvault", "uvault"); err != nil {
		fmt.Println(err)
	}

	fmt.Println("User:", vCred.APIKey)
	fmt.Println("Pass:", vCred.DecryptedKValue)
}
Output:

User: myUser
Pass: myPass@#$%^&*

func (*Credential) SetInfo

func (c *Credential) SetInfo(apiKey, keyValue, url, dirVault, fileVault string) error

SetInfo set provided information to credential vault

apiKey and keyValue are the API key and Key Value (username and password in case of Baic Auth)

Example
package main

import (
	"fmt"

	"github.com/marco-ostaska/uvault"
)

func main() {
	var vCred uvault.Credential

	if err := vCred.SetInfo("myUser", "myPass@#$%^&*", "https://xyz.ww/", "uvault", "uvault"); err != nil {
		fmt.Println(err)
	}

}
Output:

func (*Credential) UserInfo

func (c *Credential) UserInfo(dirVault, fileVault string) error

UserInfo parse HomeDir, Username, Hostname and File to vault.Credential

Jump to

Keyboard shortcuts

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