gocredo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: MIT Imports: 2 Imported by: 0

README

gocredo

Build Status Go Report Card MIT

A Golang package for creating random (and valid) credentials.

Right now, only PostgreSQL user accounts are supported.

And "gocredo" rhymes with "Freddo".

The "Credentials" struct

The package exposes the following functions which return instances of the Credentials struct:

The Credentials struct exposes the following members:

  • Username is the randomly-generated username.
  • Password is the randomly-generated password.

The Credentials struct exposes the following functions:

  • ToJSON() (string, error) returns the username and password as a JSON string.

MakeForPostgreSQL

MakeForPostgreSQL creates a set of credentials suitable for a PostgreSQL database.

package main

import (
    "fmt"
    "github.com/cariad/gocredo"
)

func main() {
    credentials, _ := gocredo.MakeForPostgreSQL()

    fmt.Println(credentials.Username)
    // xcdumcpwjfderkyjreixpjfypwlqpkuunktzjshvqpocbqwtxxlxoofdiliprtd

    fmt.Println(credentials.Password)
    // SH7Z71RKiXImpk4SEDoWqn1YzLNjkfMMglXIasOCKvyNENjXAXgpAInfnDBCBe7

    credentialsJSON, _ := credentials.ToJSON()
    fmt.Println(credentialsJSON)
    // {"username":"xcdumcpwjfderkyjreixpjfypwlqpkuunktzjshvqpocbqwtxxlxoofdiliprtd","password":"SH7Z71RKiXImpk4SEDoWqn1YzLNjkfMMglXIasOCKvyNENjXAXgpAInfnDBCBe7"}
}

Security

This package uses https://github.com/cariad/gorando to generate random values, and you should read that package's security notes.

Also, this package intentionally does not log any values.

Acknowledgements

This project uses the following packages:

Licence, credit & sponsorship

This project is published under the MIT Licence.

You don't owe me anything in return, but as an indie freelance coder there are two things I'd appreciate:

  • Credit. If your app or documentation has a credits page, please consider mentioning the projects you use.
  • Cash. If you want and are able to support future development, please consider becoming a patron or buying me a coffee. Thank you!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Credentials describes a username and password.

func MakeForPostgreSQL added in v1.0.0

func MakeForPostgreSQL() (Credentials, error)

MakeForPostgreSQL creates a set of credentials suitable for a PostgreSQL database.

func (Credentials) ToJSON added in v1.0.0

func (c Credentials) ToJSON() (string, error)

ToJSON returns the credentials as a JSON string.

Jump to

Keyboard shortcuts

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