goauthpkg

package
v0.0.0-...-c36fa23 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credential

type Credential struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Credential represent the object holding our authentication data

type HashStr

type HashStr interface {
	Generate(s string) (string, error)
	Compare(hash string, s string) error
}

HashStr is an interface consists of 2 methods for manipulating string and hash

type UserCollection

type UserCollection interface {
	// Create user in the database
	CreateUser(u *UserObj) error
	GetByUsername(username string) (UserObj, error)
	GetAllUser() (*[]string, error)
	Login(c Credential) (UserObj, error)
}

UserCollection holds function to manipulate the user collection

type UserObj

type UserObj struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
}

UserObj An object represent user in database

type UserSession

type UserSession interface {
	SaveSession(username string) (string, error)
	RetreiveSession(token string) (string, error)
	DeleteSession(token string) (string, error)
	SetCookie(w http.ResponseWriter, token string)
	InsertUser(username string) error
	RetreiveAllUsers() ([]string, error)
}

UserSession holds methods to use for session authentication

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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