common

package
v0.0.0-...-5d0e1a3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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

func Decrypt(data string) (string, error)

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

func Encrypt(data string) (string, error)

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

func GenPasswordHash(password string) ([]byte, error)

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

func GetNetmasterVersion(address string) (string, error)

GetNetmasterVersion reaches out to the specified netmaster and retrieves the "Version" key from its /version endpoint.

func IsEmpty

func IsEmpty(str string) bool

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

func ValidatePassword(password string, passwordHash []byte) bool

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

type GlobalMap map[string]string

GlobalMap is a map to hold variables(key:value pair) that can be accessed anywhere in auth_proxy

func Global

func Global() GlobalMap

Global returns `GlobalMap` singleton object

func (GlobalMap) Get

func (g GlobalMap) Get(key string) (string, error)

Get retrieves the value of the given key from `GlobalMap` params:

key: to be fetched from map

return values:

string: g[key] on success
error: relevant error if it fails to retrieve the given key's value

func (GlobalMap) Set

func (g GlobalMap) Set(key, value string) error

Set adds a key:value pair in `GlobalMap` params:

key: string; to be set in map
value: string; value for the key

return values:

error: nil on success or relevant error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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