Documentation ¶
Index ¶
- Constants
- func CheckPassword(password string, hash string) (bool, error)
- func CreateExternalJWT(storageEngine storage.Storage, userID string, ip string, hours int, ...) (string, error)
- func CreateExternalJWTNoIP(storageEngine storage.Storage, userID string, hours int, minutes int, ...) (string, error)
- func CreateInternalJWT(storageEngine storage.Storage, service string, ip string, hours int) (string, error)
- func GenerateEmailToken() (string, error)
- func HashData(data []byte) (string, error)
- func HashFile(fp string) (string, error)
- func HashPassword(password string) (string, error)
- func LoadKeyFileRSA(buf io.ReadCloser) (*rsa.PrivateKey, *rsa.PublicKey, error)
- func LoadToken(path string) (string, error)
- func NormalizeURLForHash(uri string) (string, error)
- func PathExists(path string) (bool, error)
- func ValidateExternalJWT(storageEngine storage.Storage, tokenString string, ip string, ...) (bool, int64, map[string]interface{}, error)
- func ValidateInternalJWT(storageEngine storage.Storage, tokenString string, service string, ip string, ...) (bool, error)
Constants ¶
const SkipIpValidation = "skip_ip_validation"
Variables ¶
This section is empty.
Functions ¶
func CheckPassword ¶
CheckPassword Checks a hashed password against a string
password - string, the password that will be compared hash - string, the hashed password that will be compared
Returns:
out - bool, whether the passed password matches the hash
func CreateExternalJWT ¶
func CreateExternalJWT(storageEngine storage.Storage, userID string, ip string, hours int, minutes int, payload map[string]interface{}) (string, error)
CreateExternalJWT Creates a JWT for http API authentication
userID - string, the user ID that this JWT will be used for ip - string, the IP address of the machine that will be using this JWT hours - int, amount of hours the JWT will be active for minutes - int, amount of minutes the JWT will be active for payload - map[string]interface{}, optional set of key, value pairs to be added to the JWT payload
Returns:
out - string, JWT containing the pertinent claims and signed by the global private key
func CreateExternalJWTNoIP ¶
func CreateExternalJWTNoIP(storageEngine storage.Storage, userID string, hours int, minutes int, payload map[string]interface{}) (string, error)
CreateExternalJWTNoIP Creates a JWT for http API authentication
userID - string, the user ID that this JWT will be used for ip - string, the IP address of the machine that will be using this JWT hours - int, amount of hours the JWT will be active for minutes - int, amount of minutes the JWT will be active for payload - map[string]interface{}, optional set of key, value pairs to be added to the JWT payload
Returns:
out - string, JWT containing the pertinent claims and signed by the global private key
func CreateInternalJWT ¶
func CreateInternalJWT(storageEngine storage.Storage, service string, ip string, hours int) (string, error)
CreateInternalJWT Creates a JWT for internal_api API authentication
service - string, the service that this JWT will be used for ip - string, the IP address of the machine that will be using this JWT hours - int, amount of hours the JWT will be active for
Returns:
out - string, JWT containing the pertinent claims and signed by the global private key
func GenerateEmailToken ¶
func HashData ¶
HashData Hashes the passed data with SHA3-256
data - []byte, the data that will be hashed
Returns:
out - string, hex encoded SHA3-256 hash made of the passed data
func HashFile ¶
HashFile Hashes the contents of a file with SHA3-256
fp - string, the file path for the file that will be hashes
Returns:
out - string, hex encoded SHA3-256 hash made of passed file's contents
func HashPassword ¶
HashPassword Hashes a password with bcrypt
password - string, the password that will be hashed
Returns:
out - string, a string representation of the hashed password
func LoadKeyFileRSA ¶
func LoadKeyFileRSA(buf io.ReadCloser) (*rsa.PrivateKey, *rsa.PublicKey, error)
LoadKeyFileRSA Loads RSA key from .pem file
path - string, filepath to the .pem file
Returns:
block - *rsa.PrivateKey, RSA private key loaded from file rest - *rsa.PublicKey, RSA public key loaded from file
func LoadToken ¶
LoadToken Loads authentication token from the specified path Args:
path - string, the file path of the authentication token
Returns:
out - string, JWT token loaded from the passed file
func NormalizeURLForHash ¶
NormalizeURLForHash Normalizes a URL for hash calculation Strips url of all query parameters and fragments Args:
uri - string, url that will be normalized for hashing
Returns:
out - string, url that has been stripped of all of its query parameters and fragments
func PathExists ¶
PathExists Checks if a file path exists on the filesystem Args:
path - string, the file path of the source file
Returns:
out - bool, whether the filepath was found to exist on the filesystem
func ValidateExternalJWT ¶
func ValidateExternalJWT(storageEngine storage.Storage, tokenString string, ip string, payload map[string]interface{}) (bool, int64, map[string]interface{}, error)
ValidateExternalJWT Validates a JWT for internal_api API authentication
tokenString - string, JWT string that will be validated ip - string, IP address of the machine that will be using this JWT payload - map[string]interface{}, optional set of key, value pairs to be checked for in the JWT payload
Returns:
valid - bool, success status for the JWT validation userID - string, id of the user stored in the JWT payload - map[string]interface, payload of the jwt
func ValidateInternalJWT ¶
func ValidateInternalJWT(storageEngine storage.Storage, tokenString string, service string, ip string, validateIP bool) (bool, error)
ValidateInternalJWT Validates a JWT for internal_api API authentication
tokenString - string, JWT string that will be validated service - string, service that this JWT will be used for ip - string, IP address of the machine that will be using this JWT validateIP - bool, validate the IP stored inside the JWT
Returns:
out - bool, success status for the JWT validation
Types ¶
This section is empty.