dal

package
v0.3.0-dev.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

README

Contains the data access layer, used by the API to interact with the database.

The current implementation is 100% in local memory. The database support will be added later.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHashAndPassword

func CompareHashAndPassword(hashedPassword string, password string) bool

CompareHashAndPassword receives a plaintext password and its hash, and returns true if they match.

func GenerateRandomToken

func GenerateRandomToken(length int) (string, error)

GenerateRandomToken generates a random character token.

func HashPassword

func HashPassword(pwd string) (string, error)

HashPassword receives a plaintext password and returns its hashed equivalent.

Types

type DataAccess

type DataAccess interface {
	Initialize() error
	GroupAddUser(string, string) error
	GroupCreate(rest.Group) error
	GroupDelete(string) error
	GroupExists(string) (bool, error)
	GroupGet(string) (rest.Group, error)
	GroupGrantRole() error
	GroupList() ([]rest.Group, error)
	GroupRemoveUser(string, string) error
	GroupRevokeRole() error
	GroupUpdate(rest.Group) error
	GroupUserList(group string) ([]rest.User, error)
	GroupUserAdd(group string, user string) error
	GroupUserDelete(group string, user string) error

	UserAuthenticate(string, string) (bool, error)
	UserCreate(rest.User) error
	UserDelete(string) error
	UserExists(string) (bool, error)
	UserGet(string) (rest.User, error)
	UserGroupList(user string) ([]rest.Group, error)
	UserGroupAdd(user string, group string) error
	UserGroupDelete(user string, group string) error
	UserList() ([]rest.User, error)
	UserUpdate(rest.User) error

	TokenEvaluate(token string) bool
	TokenGenerate(user string, duration time.Duration) (rest.Token, error)
	TokenInvalidate(token string) error
	TokenRetrieveByUser(user string) (rest.Token, error)
	TokenRetrieveByToken(token string) (rest.Token, error)
}

DataAccess represents a common DataAccessObject, backed either by a database or an in-memory datastore.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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