pkg

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const BCRYPT_DEFAULT_COST = bcrypt.DefaultCost + 4

Variables

This section is empty.

Functions

func Check_credential

func Check_credential(db *gorm.DB, config_file string, auth Auth) bool

func Create_read_pepper

func Create_read_pepper(fname string) string

Function to read in pepper

looks for config file or creates one

func Get_input

func Get_input(prompt string) string

func Hash_SaltPepper_Password

func Hash_SaltPepper_Password(password string, salt string, pepper string) []byte

func Log_if_fatal

func Log_if_fatal(e error)

func Pretty_print

func Pretty_print(obj any)

Function for printing Objects

prints any object (as JSON) as long as it can be serialized to JSON

func Str_random

func Str_random(n int) string

str_random

produce string of random characters of length n

Types

type Auth

type Auth struct {
	Username string
	Password string
}

Credential type

with raw input

func Get_auth_from_term

func Get_auth_from_term() Auth

Function to retrieve name/password from terminal

- will prompt for user input and - will hide password input in terminal

type Credential

type Credential struct {
	Username string
	Salt     string
	Hash     string
}

Credential type

with hashed password after adding salt and pepper

func Make_credential

func Make_credential(username string, password string, pepper string) Credential

MakeCredential

generates a credential from username, password and pepper

type CredentialSQL

type CredentialSQL struct {
	gorm.Model
	Username string `gorm:"unique"`
	Salt     string
	Hash     string
}

Credential type

with hashed password after adding salt and pepper ready to be put in DB

func Make_credential_sql

func Make_credential_sql(username string, password string, pepper string) CredentialSQL

MakeCredentialSQL

generates a credential from username, password and pepper

func Upsert_auth_as_credential_to_db

func Upsert_auth_as_credential_to_db(db *gorm.DB, config_file string, auth Auth) CredentialSQL

Jump to

Keyboard shortcuts

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