go-credentials

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT

README

go-credentials

Build Quality Gate Status Coverage Go Report Card

Welcome to go-credentials!

This project is being built out of a need for a library to manage credentials files (similar to AWS credentials), their attributes, sessions, and environment variables.

go-credentials logo

The Credential API is broken down into two pieces, each with their own functionality:

  1. Factory: responsible for setting variables that are global to your application, and;
    • Set alternate keys for username/password (e.g. ACCESS_TOKEN/SECRET_KEY).
    • Set the output type of the credentials (only .ini currently implemented).
  2. Credential: represents a user's credentials.
    • Username/Password defined on model.
    • Set Attributes.
    • Get Attributes.
    • Read values from Environment variables.
    • Load from .ini File.

To get started, is all you need to do is the following:

export TEST_APP_USERNAME="my.username"
export TEST_APP_PASSWORD="Password1!"
export TEST_APP_ATTRIBUTE="an attribute with a value"
package main

import (
    "github.com/engi-fyi/go-credentials/credential"
    "github.com/engi-fyi/go-credentials/factory"
)

func main() {
    myFact, _ := factory.New("test_app", false)
    myFact.Initialize()
    myCred, _ := credential.LoadFromEnvironment(myFact)
    print(myCred.Username)                  // "my.username"
    print(myCred.Password)                  // "Password1!"
    print(myCred.GetAttribute("attribute")) // "an attribute with a value"
    myCred.Save()                           // credentials file created at
                                            // ~/.test_app/credentials
}

Directories

Path Synopsis
Package credential provides the base implementation detail for the go-credentials library.
Package credential provides the base implementation detail for the go-credentials library.
Package factory provides an API for managing application-level credential details.
Package factory provides an API for managing application-level credential details.
Package global contains constants, test variables, and some minor utility functions.
Package global contains constants, test variables, and some minor utility functions.
Package profile contains all of the code for managing multiple credential files.
Package profile contains all of the code for managing multiple credential files.
Package serializer is responsible for de/serializing Credential and Profile objects into different file formats.
Package serializer is responsible for de/serializing Credential and Profile objects into different file formats.

Jump to

Keyboard shortcuts

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