pass

package
v0.0.0-...-8b20b1e Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package defines helpers structs to store credentials

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Host     string
	User     string
	Password string
	Name     string // of the database
	Port     int    // default to 5432
}

DB provides access to a database

func NewDB

func NewDB() (out DB, err error)

NewDB uses env variables to build DB credentials : DB_HOST, DB_USER, DB_PASSWORD, DB_NAME

func (DB) ConnectPostgres

func (db DB) ConnectPostgres() (*sql.DB, error)

ConnectPostgres builds a connection string and connect using postgres as driver name.

type EncryptedID

type EncryptedID string

EncryptedID is the public version of the DB id of record. In particular, it is suitable to be included in URLs

type Encrypter

type Encrypter [16]byte

Encrypter is used to encrypt exposed data, such as students IDs.

func NewEncrypter

func NewEncrypter(env string) (Encrypter, error)

NewEncrypter read the given ENV variable to build an encrypter.

func NewEncrypterFromKey

func NewEncrypterFromKey(key string) Encrypter

func (Encrypter) DecryptID

func (key Encrypter) DecryptID(enc EncryptedID) (int64, error)

func (Encrypter) DecryptJSON

func (pass Encrypter) DecryptJSON(data string, dst interface{}) error

DecryptJSON performs the reverse operation of EncryptJSON, storing the data into `dst`

func (Encrypter) DecryptPassword

func (key Encrypter) DecryptPassword(crypted []byte) string

DecryptPassword returns the clear user password.

func (Encrypter) EncryptID

func (key Encrypter) EncryptID(ID int64) EncryptedID

func (Encrypter) EncryptJSON

func (pass Encrypter) EncryptJSON(data interface{}) (string, error)

EncryptJSON marshals `data`, encrypts and espace using `base64.RawURLEncoding`

func (Encrypter) EncryptPassword

func (key Encrypter) EncryptPassword(pass string) []byte

EncryptPassword crypt the user provided password

type SMTP

type SMTP struct {
	Host string
	// Should be a valid adress mail
	User     string
	Password string
	Port     string
}

SMTP provides mailing credentials.

func NewSMTP

func NewSMTP() (out SMTP, err error)

NewSMTP uses env variables to build SMTP credentials : SMTP_HOST, SMTP_USER, SMTP_PASSWORD, SMTP_PORT

Jump to

Keyboard shortcuts

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