Documentation ¶
Overview ¶
Package auth implements an authentication system for Shelves to authenticate users, by file or LDAP.
Index ¶
- func AddUser(username string, pwd string) error
- func Connect(sqlitefile string) error
- func PWDCryptComp(hashedPassword string, password string) error
- func PWDECrypt(password string, cost int) (string, error)
- func PopulateDB(sqlitefile string) error
- func UserAuth(username string, webpwd string) (error, error)
- func UserPwdChange(username string, newpwd string) error
- type Users
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUser ¶
AddUser takes a string variable called username and a string variable called pwd. It then produces a hashed password from the crypt.go file in package auth, and inserts it into the SQL database provided.
func Connect ¶
Connect connects to the sqlite DB passed onto the function through the global variable 'db'.
func PWDCryptComp ¶
PWDCryptComp takes two arguments, the hashed Password from generation earlier, and the password sent to Shelves from the Web Service, for example. It then returns an error type, which is nil if the password matches, or an error if it doesn't match.
func PWDECrypt ¶
PWDECrypt takes two arguments, the password to be encrypted, and the cost. It then returns and the hashed Password generated in a string form. It also returns an error value, which normally would be nil, but if anything went wrong it would return the error.
func PopulateDB ¶
PopulateDB removes the sqlite DB, and recreates and populates it.
func UserAuth ¶
UserAuth takes a string variable called 'username' and a string variable called webpwd. It grabs the encrypted password from the sqlite database and then compares it using the crypt.go file from the auth package with the password passed to the function.
func UserPwdChange ¶
UserPwdChange takes two arguments, a username and a new password, both a string type. It then checks if the username exists in the DB. If it does, it generates a new hashed password and updates the record of the User with it.