Documentation ¶
Index ¶
- Constants
- func Decrypt(data string) (string, error)
- func EnableHSTS(w http.ResponseWriter)
- func Encrypt(data string) (string, error)
- func GenPasswordHash(password string) ([]byte, error)
- func GetNetmasterVersion(address string) (string, error)
- func IsEmpty(str string) bool
- func SetDefaultResponseHeaders(w http.ResponseWriter)
- func Trace() string
- func Untrace(s string)
- func ValidatePassword(password string, passwordHash []byte) bool
- type GlobalMap
Constants ¶
const HSTSValue = "max-age=15768000"
HSTSValue is the value of the Strict-Transport-Security header we set. 15768000 = 6 months
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt decrypts the given string with the RSA private key. params:
data: String to decode + decrypt, which is in a base64 encoded format
return values:
string: Decrypted text error: nil if base64 decode and RSA decrypt succeeds, else the appropriate decode/decrypt failure
func EnableHSTS ¶
func EnableHSTS(w http.ResponseWriter)
EnableHSTS adds the Strict-Transport-Security header. it's a separate function because it's called from two different places.
func Encrypt ¶
Encrypt encrypts the given string with the RSA public key. params:
data: String to be encrypted + encoded
return values:
string: Encrypted with the public key and base64 encoded error: nil if base64 encode and RSA encrypt succeeds, else the appropriate encode/encrypt failure
func GenPasswordHash ¶
GenPasswordHash generates a hash from the provided password. params:
password: plaintext password string
return values:
[]byte: hash of password error: nil if successful, otherwise the error from bcrypt.GenerateFromPassword()
func GetNetmasterVersion ¶
GetNetmasterVersion reaches out to the specified netmaster and retrieves the "Version" key from its /version endpoint.
func IsEmpty ¶
IsEmpty checks if the given string is empty or not params:
str: string that needs to be checked
return values:
true if the string is empty otherwise false
func SetDefaultResponseHeaders ¶
func SetDefaultResponseHeaders(w http.ResponseWriter)
SetDefaultResponseHeaders sets the default response headers.
func Trace ¶
func Trace() string
Trace emits a debug level log message with info of the caller function.
Returns:
name of caller function if no error, "" otherwise.
func Untrace ¶
func Untrace(s string)
Untrace should be used with Trace function as defer Untrace(Trace()).
Parameters:
s: name of function being traced. This is the output from Trace function.
Returns nothing
func ValidatePassword ¶
ValidatePassword returns true if the supplied password's hash matches the correct password's hash, false otherwise. params:
password: plaintext password from the user passwordHash: hash to compare the password against
return values:
bool: true if the password matches the hash, otherwise false
Types ¶
type GlobalMap ¶
GlobalMap is a map to hold variables(key:value pair) that can be accessed anywhere in auth_proxy