config

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: GPL-3.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAdminEmailFromFromEnvOrPanic added in v0.3.1

func GetAdminEmailFromFromEnvOrPanic(defaultAdminEmail string) string

GetAdminEmailFromFromEnvOrPanic returns the admin user to be used with JWT authentication from the content of the env variable : ADMIN_EMAIL : string containing the username to use for the administrative account

func GetAdminIdFromFromEnvOrPanic added in v0.3.1

func GetAdminIdFromFromEnvOrPanic(defaultAdminId int) int

GetAdminIdFromFromEnvOrPanic returns the admin user id to be used with JWT authentication from the content of the env variable ADMIN_ID : string containing the user id to use for the administrative account

func GetAdminPasswordFromFromEnvOrPanic added in v0.3.1

func GetAdminPasswordFromFromEnvOrPanic() string

GetAdminPasswordFromFromEnvOrPanic returns the admin password to be used with JWT authentication from the content of the env variable :

ADMIN_PASSWORD : string containing the password to use for the administrative account

func GetAdminUserFromFromEnvOrPanic added in v0.3.1

func GetAdminUserFromFromEnvOrPanic(defaultAdminUser string) string

GetAdminUserFromFromEnvOrPanic returns the admin user to be used with JWT authentication from the content of the env variable : ADMIN_USER : string containing the username to use for the administrative account

func GetAllowedHostsFromEnvOrPanic added in v0.3.7

func GetAllowedHostsFromEnvOrPanic() []string

GetAllowedHostsFromEnvOrPanic returns a list of valid TCP/IP addresses based on the values of env variable ALLOWED_HOSTS

ALLOWED_HOSTS : comma separated list of valid IP addresses
in case the ENV variable ALLOWED_HOSTS exists and contains invalid Host addresses the functions panics

func GetAllowedIpsFromEnvOrPanic added in v0.3.2

func GetAllowedIpsFromEnvOrPanic(defaultAllowedIps []string) []string

GetAllowedIpsFromEnvOrPanic returns a list of valid TCP/IP addresses based on the values of env variable ALLOWED_IP

ALLOWED_IP : comma separated list of valid IP addresses
 in case the ENV variable ALLOWED_IP exists and contains invalid IP addresses the functions panics
if the ENV variable ALLOWED_IP does not exist the function returns the defaultAllowedIps or panic if invalid

func GetJwtDurationFromEnvOrPanic added in v0.3.1

func GetJwtDurationFromEnvOrPanic(defaultJwtDuration int) int

GetJwtDurationFromEnvOrPanic returns a number string based on the values of environment variable : JWT_DURATION_MINUTES : int value between 1 and 14400 minutes, 10 days seems an extreme max value the parameter defaultJwtDuration will be used if this env variable is not defined in case the ENV variable JWT_DURATION_MINUTES exists and contains an invalid integer the functions ends execution with Fatalreturns 0 and an error

func GetJwtIssuerFromEnvOrPanic added in v0.3.1

func GetJwtIssuerFromEnvOrPanic() string

GetJwtIssuerFromEnvOrPanic returns a secret to be used with JWT based on the content of the env variable JWT_ISSUER_ID : should exist and contain a string with your secret or this function will panic

func GetJwtSecretFromEnvOrPanic added in v0.3.1

func GetJwtSecretFromEnvOrPanic() string

GetJwtSecretFromEnvOrPanic returns a secret to be used with JWT based on the content of the env variable JWT_SECRET : should exist and contain a string with your secret or this function will panic

func GetListenIpFromEnvOrPanic added in v0.3.2

func GetListenIpFromEnvOrPanic(defaultSrvIp string) string

GetListenIpFromEnvOrPanic returns a valid TCP/IP listening address based on the values of environment variable :

SRV_IP : int value between 1 and 65535 (the parameter defaultPort will be used if env is not defined)
 in case the ENV variable PORT exists and contains an invalid integer the functions panics

func GetPgDbDsnUrlFromEnvOrPanic added in v0.3.9

func GetPgDbDsnUrlFromEnvOrPanic(defaultIP string, defaultPort int,
	defaultDbName string, defaultDbUser string, defaultSSL string) string

GetPgDbDsnUrlFromEnvOrPanic returns a valid DSN connection string based on the values of environment variables :

	DB_HOST : string containing a valid Ip Address to use for DB connection
	DB_PORT : int value between 1 and 65535
	DB_NAME : string containing the database name
	DB_USER : string containing the database username
	DB_PASSWORD : string containing the database user password
 DB_SSL_MODE : string containing ssl mode (disable|allow|prefer|require|verify-ca|verify-full)
 more info on libpg SSL : https://www.postgresql.org/docs/11/libpq-ssl.html#LIBPQ-SSL-PROTECTION
 more info : https://pkg.go.dev/github.com/jackc/pgconn#ParseConfig

func GetPortFromEnvOrPanic added in v0.3.1

func GetPortFromEnvOrPanic(defaultPort int) int

GetPortFromEnvOrPanic returns a valid TCP/IP listening port based on the values of environment variable :

PORT : int value between 1 and 65535 (the parameter defaultPort will be used if env is not defined)
 in case the ENV variable PORT exists and contains an invalid integer the functions panics

func VerifyPasswordComplexity added in v0.3.1

func VerifyPasswordComplexity(s string) bool

VerifyPasswordComplexity checks if the password meets the minimum requirements of complexity At least one lowercase letter,one uppercase letter, one digit and one special character No white space, #, or | or ' character in it

Types

This section is empty.

Jump to

Keyboard shortcuts

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