# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# README
go-credentials
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.
The Credential API is broken down into two pieces, each with their own functionality:
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 (environment, ini, and json supported).
- Responsible for logging.
Credential
: represents a user's credentials.- Username/Password defined on model.
- Can have a profile.
- Save and Load Credentials (and Profiles).
Profile
: represents a profile, containing variables specific to a profile.- Username/Password defined on model.
- Set Attributes (including sections).
- Get Attributes (including sections).
To get started, is all you need to do is create the following files.
~/.gcea/credentials
[default]
username = [email protected]
password = !my_test_pass==word
main.go
package main
import (
"github.com/engi-fyi/go-credentials/credential"
"github.com/engi-fyi/go-credentials/factory"
"fmt"
"time"
)
func main() {
myFact, _ := factory.New("gcea", false) // go-credentials-example-application
myFact.ModifyLogger("trace", true) // let's see under the hood and make it pretty.
myCredential, _ := credential.Load(myFact)
fmt.Printf("Username: %s\n", myCredential.Username)
fmt.Printf("Password: %s\n\n", myCredential.Password)
myCredential.SetSectionAttribute("metadata", "last_updated", time.Now().Format("02/01/2006 15:04:05"))
myCredential.Save()
myCredential = nil
yourCredential, _ := credential.Load(myFact)
fmt.Printf("Username: %s\n", yourCredential.Username)
fmt.Printf("Password: %s\n", yourCredential.Password)
lastUpdated, _ := yourCredential.GetSectionAttribute("metadata", "last_updated")
fmt.Printf("Last Updated: %s\n", lastUpdated)
}