db

package
Version: v0.0.0-...-a91455d Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeDBCred

func MakeDBCred(str string) string

MakeDBCred hides DB credential in connection string

Types

type DB

type DB struct {
	*sqlx.DB
	IsDBInitialized bool
}

DB is an adopter for sqlx.DB and implements

func NewUserRegistryMySQL

func NewUserRegistryMySQL(datasource string) (*DB, error)

NewUserRegistryMySQL opens a connection to a MySQL database

func NewUserRegistryPostgres

func NewUserRegistryPostgres(datasource string) (*DB, error)

NewUserRegistryPostgres opens a connection to a postgres database

func (*DB) BeginTx

func (db *DB) BeginTx() RKSyncCATx

BeginTx implements BeginTx method of RKSyncCADB interface

func (*DB) IsInitialized

func (db *DB) IsInitialized() bool

IsInitialized returns true if db is initialized, else false

type RKSyncCADB

type RKSyncCADB interface {
	IsInitialized() bool
	Select(dest interface{}, query string, args ...interface{}) error
	Exec(query string, args ...interface{}) (sql.Result, error)
	NamedExec(query string, arg interface{}) (sql.Result, error)
	Rebind(query string) string
	MustBegin() *sqlx.Tx
	BeginTx() RKSyncCATx
}

RKSyncCADB is the interface with functions implemented by sqlx.DB object that are used by rksync CA server

type RKSyncCATx

type RKSyncCATx interface {
	Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
	Select(dest interface{}, query string, args ...interface{}) error
	Rebind(query string) string
	Exec(query string, args ...interface{}) (sql.Result, error)
	Commit() error
	Rollback() error
}

RKSyncCATx is the interface with functions implemented by sqlx.Tx object that are used by rksync CA server

type User

type User struct {
	registry.UserInfo
	// contains filtered or unexported fields
}

User is the database representation of a user

func NewDBUser

func NewDBUser(userRec *UserRecord, db *DB) *User

NewDBUser creates a User object from the DB user record

func (*User) GetAttribute

func (u *User) GetAttribute(name string) (*api.Attribute, error)

GetAttribute returns the value for an attribute name

func (*User) GetAttributes

func (u *User) GetAttributes(attrNames []string) ([]api.Attribute, error)

GetAttributes returns the requested attributes.

func (*User) GetFailedLoginAttempts

func (u *User) GetFailedLoginAttempts() int

GetFailedLoginAttempts returns the number of times the user has entered an incorrect password

func (*User) GetMaxEnrollments

func (u *User) GetMaxEnrollments() int

GetMaxEnrollments returns the max enrollments of the user

func (*User) GetName

func (u *User) GetName() string

GetName returns the enrollment ID of the user

func (*User) IncrementIncorrectPasswordAttempts

func (u *User) IncrementIncorrectPasswordAttempts() error

IncrementIncorrectPasswordAttempts updates the incorrect password count of user

func (*User) Login

func (u *User) Login(pass string, caMaxEnrollment int) error

Login the user with a password

func (*User) LoginComplete

func (u *User) LoginComplete() error

LoginComplete completes the login process by incrementing the state of the user

type UserRecord

type UserRecord struct {
	Name                      string `db:"id"`
	Pass                      []byte `db:"token"`
	Attributes                string `db:"attributes"`
	State                     int    `db:"state"`
	MaxEnrollment             int    `db:"max_enrollments"`
	IncorrectPasswordAttempts int    `db:"incorrect_password_attempts"`
}

UserRecord defines the properties of user

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL