authentication

package
v0.0.0-...-71dfe91 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeCredentials

func ChangeCredentials(userID, username, password string) (err error)

ChangeCredentials : change credentials

func CheckTheValidityOfTheToken

func CheckTheValidityOfTheToken(token string) (newToken string, err error)

CheckTheValidityOfTheToken : check token

func CheckTheValidityOfTheTokenFromHTTPHeader

func CheckTheValidityOfTheTokenFromHTTPHeader(w http.ResponseWriter, r *http.Request) (writer http.ResponseWriter, newToken string, err error)

CheckTheValidityOfTheTokenFromHTTPHeader : get token from HTTP header

func CreateDefaultUser

func CreateDefaultUser(username, password string) (err error)

CreateDefaultUser = created efault user

func CreateNewUser

func CreateNewUser(username, password string) (userID string, err error)

CreateNewUser : create new user

func GetAllUserData

func GetAllUserData() (allUserData map[string]interface{}, err error)

GetAllUserData : get all user data

func GetUserID

func GetUserID(token string) (userID string, err error)

GetUserID : get user ID

func Init

func Init(databasePath string, validity int) (err error)

Init : databasePath = Path to authentication.json

func ReadUserData

func ReadUserData(userID string) (userData map[string]interface{}, err error)

ReadUserData : load user date

func RemoveUser

func RemoveUser(userID string) (err error)

RemoveUser : remove user

func SHA256

func SHA256(secret, salt string) string

SHA256 : password + salt = sha256 string

func SetCookieToken

func SetCookieToken(w http.ResponseWriter, token string) http.ResponseWriter

SetCookieToken : set cookie

func SetDefaultUserData

func SetDefaultUserData(defaults map[string]interface{}) (err error)

SetDefaultUserData : set default user data

func UserAuthentication

func UserAuthentication(username, password string) (token string, err error)

UserAuthentication : user authentication

func WriteUserData

func WriteUserData(userID string, userData map[string]interface{}) (err error)

WriteUserData : save user date

Types

type Cookie struct {
	Name       string
	Value      string
	Path       string
	Domain     string
	Expires    time.Time
	RawExpires string
}

Cookie : cookie

Jump to

Keyboard shortcuts

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