Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPasswordHash(password, hash string) bool
- func HashPassword(password string) (string, error)
- type Key
- type KeyDB
- type KeyDBImpl
- func (db *KeyDBImpl) AddKnownHost(ctx context.Context, hostIdentifier string, key ssh.PublicKey) (err error)
- func (db *KeyDBImpl) CheckKnownHost(ctx context.Context, hostIdentifier string, key ssh.PublicKey) (ok bool, err error)
- func (db *KeyDBImpl) GetHostKey(ctx context.Context) (pemString []byte, err error)
- func (db *KeyDBImpl) InitKeyTable(ctx context.Context, privatePem string) error
- func (db *KeyDBImpl) SetHostKey(ctx context.Context, pemBytes []byte) error
- type KeyImpl
- type User
- type UserDB
- type UserDBImpl
- func (db *UserDBImpl) Authenticate(ctx context.Context, username, password string) (User, error)
- func (db *UserDBImpl) DeleteUser(ctx context.Context, id uint) error
- func (db *UserDBImpl) GetAll(ctx context.Context) (users []User, err error)
- func (db *UserDBImpl) GetByEmail(ctx context.Context, email string) (user User, err error)
- func (db *UserDBImpl) GetByUsername(ctx context.Context, username string) (user User, err error)
- func (db *UserDBImpl) GetUser(ctx context.Context, where map[string]interface{}, limit int) (user User, err error)
- func (db *UserDBImpl) Register(ctx context.Context, user User, passwordHash string) error
- func (db *UserDBImpl) Update(ctx context.Context, user User) (err error)
- func (db *UserDBImpl) UpdatePassword(ctx context.Context, user User, passwordHash string) error
- type UserImpl
- func (u *UserImpl) GetCreatedAt() time.Time
- func (u *UserImpl) GetEmail() string
- func (u *UserImpl) GetID() uint
- func (u *UserImpl) GetNickname() string
- func (u *UserImpl) GetUpdatedAt() time.Time
- func (u *UserImpl) GetUsername() string
- func (u *UserImpl) IsDeleted() bool
- func (u *UserImpl) String() string
- type UserPassword
Constants ¶
View Source
const (
HASHCOST = 10
)
Variables ¶
View Source
var ( ErrKeyNotFound = errors.New("no key found") ErrInvalidHostIdentifier = errors.New("invalid host identifier") ErrHostAlreadyKnown = errors.New("host already known") ErrTableNotFound = errors.New("table not found") )
View Source
var ( ErrUserNotFound = errors.New("no user found") ErrUserAlreadyExists = errors.New("user already exists") ErrRegisteringUser = errors.New("error registering user") )
View Source
var (
ErrInvalidPassword = errors.New("invalid password")
)
Functions ¶
func CheckPasswordHash ¶
func HashPassword ¶
Types ¶
type Key ¶
type Key interface {
// GetID returns the key's ID.
GetID() uint
// GetIdentifier returns the key's identifier.
GetIdentifier() string
// GetKey returns the key's key.
GetKey() string
// GetCreatedAt returns the key's creation time.
GetCreatedAt() time.Time
// GetUpdatedAt returns the key's last update time.
GetUpdatedAt() time.Time
// IsDeleted returns true if the key is deleted.
IsDeleted() bool
}
type KeyDB ¶
type KeyDB interface {
// SetHostKey sets the private key for the host
SetHostKey(ctx context.Context, pemBytes []byte) error
// returns the private key for the host, pem encoded
GetHostKey(ctx context.Context) (pemBytes []byte, err error)
// adds a new known host to the database
AddKnownHost(ctx context.Context, hostIdentifier string, key ssh.PublicKey) error
// checks if the given host is known
CheckKnownHost(ctx context.Context, hostIdentifier string, key ssh.PublicKey) (bool, error)
}
type KeyDBImpl ¶
func (*KeyDBImpl) AddKnownHost ¶
func (*KeyDBImpl) CheckKnownHost ¶
func (*KeyDBImpl) GetHostKey ¶
func (*KeyDBImpl) InitKeyTable ¶
type KeyImpl ¶
type KeyImpl struct {
ID uint
Identifier string
Key string
// contains filtered or unexported fields
}
func (*KeyImpl) GetCreatedAt ¶
func (*KeyImpl) GetIdentifier ¶
func (*KeyImpl) GetUpdatedAt ¶
type User ¶
type User interface {
// GetID returns the user's ID.
GetID() uint
// GetUsername returns the user's username.
GetUsername() string
// GetNickname returns the user's nickname.
GetNickname() string
// GetEmail returns the user's email.
GetEmail() string
// GetCreatedAt returns the user's creation time.
GetCreatedAt() time.Time
// GetUpdatedAt returns the user's last update time.
GetUpdatedAt() time.Time
// IsDeleted returns true if the user is deleted.
IsDeleted() bool
// String returns a string representation of the user.
String() string
}
type UserDB ¶
type UserDB interface {
// Register registers a new user in the database.
Register(ctx context.Context, user User, password string) error
// GetAll retrieves all users from the database.
GetAll(ctx context.Context) ([]User, error)
// GetUser retrieves a user from the database by its ID.
GetUser(ctx context.Context, where map[string]interface{}, limit int) (User, error)
// GetByUsername retrieves a user from the database by its username.
GetByUsername(ctx context.Context, username string) (User, error)
// GetByEmail retrieves a user from the database by its email.
GetByEmail(ctx context.Context, email string) (User, error)
// Update updates a user in the database.
Update(ctx context.Context, user User) error
// UpdatePassword updates a user's password in the database.
UpdatePassword(ctx context.Context, user User, password string) error
// DeleteUser deletes a user from the database.
DeleteUser(ctx context.Context, id uint) error
// Authenticate authenticates a user by its username and password.
Authenticate(ctx context.Context, username, password string) (User, error)
}
type UserDBImpl ¶
func (*UserDBImpl) Authenticate ¶
func (*UserDBImpl) DeleteUser ¶
func (db *UserDBImpl) DeleteUser(ctx context.Context, id uint) error
func (*UserDBImpl) GetAll ¶
func (db *UserDBImpl) GetAll(ctx context.Context) (users []User, err error)
func (*UserDBImpl) GetByEmail ¶
func (*UserDBImpl) GetByUsername ¶
func (*UserDBImpl) Update ¶
func (db *UserDBImpl) Update(ctx context.Context, user User) (err error)
func (*UserDBImpl) UpdatePassword ¶
type UserImpl ¶
type UserImpl struct {
ID uint
Username string
Nickname sql.NullString
Email string
// contains filtered or unexported fields
}
func (*UserImpl) GetCreatedAt ¶
func (*UserImpl) GetNickname ¶
func (*UserImpl) GetUpdatedAt ¶
func (*UserImpl) GetUsername ¶
type UserPassword ¶
Click to show internal directories.
Click to hide internal directories.