auth

package
v0.0.0-...-f9f63b7 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2015 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package auth implements an authentication system for Shelves to authenticate users, by file or LDAP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUser

func AddUser(username string, pwd string) error

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

func Connect(sqlitefile string) error

Connect connects to the sqlite DB passed onto the function through the global variable 'db'.

func PWDCryptComp

func PWDCryptComp(hashedPassword string, password string) error

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

func PWDECrypt(password string, cost int) (string, error)

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

func PopulateDB(sqlitefile string) error

PopulateDB removes the sqlite DB, and recreates and populates it.

func UserAuth

func UserAuth(username string, webpwd string) (error, error)

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

func UserPwdChange(username string, newpwd string) error

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.

Types

type Users

type Users struct {
	ID            int    `db:"ID"`
	Username      string `db:"Username"`
	CryptPassword string `db:"CryptPassword"`
}

Users defines the structure of the sqlite3 Users database. The database contains the User's ID, Username and HashedPassword.

Jump to

Keyboard shortcuts

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