Documentation ¶
Index ¶
- func Authenticated(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func DeleteUser(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func GetPermission(user, privilege string) bool
- func GetUser(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func HashString(s string) string
- func LoadUserDatabase(c *cli.Context) error
- func Permission(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func SetUser(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func TokenUser(t string) string
- func ValidatePassword(user, pass string) bool
- func ValidateToken(t string) bool
- type DatabaseService
- type FileService
- type UserIOService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticated ¶
func Authenticated(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
Authenticated implements the Authenticated(user,pass) function. This accepts a username and password string, and determines if they are authenticated using the users database.
func DeleteUser ¶
func DeleteUser(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
DeleteUser implements the DeleteUser() function. For a privileged user, this will delete a record from the persistent user database. Returns true if the name was deleted, else false if it was not a valid username.
func GetPermission ¶
GetPermission returns a boolean indicating if the given username and privilege are valid and set. If the username or privilege does not exist, then the reply is always false.
func GetUser ¶
func GetUser(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
GetUser implements the GetUser() function. This returns a struct defining the persisted information about an existing user in the user database.
func HashString ¶
HashString converts a given string to it's hash. This is used to manage passwords as opaque objects.
func LoadUserDatabase ¶
loadUserDatabase uses command line options to locate and load the authorized users database, or initialize it to a helpful default.
func Permission ¶
func Permission(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
Permission implements the Permission(user,priv) function. It returns a boolean value indicating if the given username has the given permission.
func SetUser ¶
func SetUser(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
SetUser implements the SetUser() function. For the super user, this function can be used to update user data in the persistent use database for the Ego web server.
func TokenUser ¶
TokenUser is a helper function that calls the builtin cipher.token() and returns the user field.
func ValidatePassword ¶
ValidatePassword checks a username and password against the database and returns true if the user exists and the password is valid.
func ValidateToken ¶
validateToken is a helper function that calls the builtin cipher.validate(). The optional second argument (true) tells the function to generate an error state for the various ways the token was considered invalid.
Types ¶
type DatabaseService ¶
type DatabaseService struct {
// contains filtered or unexported fields
}
func (*DatabaseService) DeleteUser ¶
func (pg *DatabaseService) DeleteUser(name string) error
func (*DatabaseService) Flush ¶
func (pg *DatabaseService) Flush() error
Required interface, but does no work for the Database service.
type FileService ¶
type FileService struct {
// contains filtered or unexported fields
}
func (*FileService) DeleteUser ¶
func (f *FileService) DeleteUser(name string) error
func (*FileService) Flush ¶
func (f *FileService) Flush() error
type UserIOService ¶
type UserIOService interface { ReadUser(name string, doNotLog bool) (defs.User, error) WriteUser(user defs.User) error DeleteUser(name string) error ListUsers() map[string]defs.User Flush() error }
var AuthService UserIOService
func NewDatabaseService ¶
func NewDatabaseService(connStr, defaultUser, defaultPassword string) (UserIOService, error)
func NewFileService ¶
func NewFileService(userDatabaseFile, defaultUser, defaultPassword string) (UserIOService, error)