Documentation ¶
Index ¶
Constants ¶
const ( // RightDownload refers to the right to download/view a file. RightDownload = "fs.download" // RightFsView refers to the right to view everything related to // the filesystem and history. RightFsView = "fs.view" // RightFsEdit refers to the right to edit the filesystem. // This includes pinning. RightFsEdit = "fs.edit" // RightRemotesView is the right to view the remote list. RightRemotesView = "remotes.view" // RightRemotesEdit is the right to edit the remote list. RightRemotesEdit = "remotes.edit" )
Variables ¶
var ( // DefaultRights is a list of rights that users will get // if no other explicit rights are given. They are identical // to the admin role currently. DefaultRights = []string{ RightDownload, RightFsView, RightFsEdit, RightRemotesView, RightRemotesEdit, } // AllRights is a map that can be quickly used to check // if a right is valid or not. AllRights = map[string]bool{ RightDownload: true, RightFsView: true, RightFsEdit: true, RightRemotesView: true, RightRemotesEdit: true, } )
Functions ¶
func HashPassword ¶
HashPassword creates a new hash and salt from a password.
Types ¶
type User ¶
User is one user that is stored in the database. The passwords are stored as scrypt hash with added salt.
func UserFromCapnp ¶
UserFromCapnp takes a capnp.user and returns a regular User from it.
type UserDatabase ¶
type UserDatabase struct {
// contains filtered or unexported fields
}
UserDatabase is a badger db that stores user information, using the user name as unique key.
func NewUserDatabase ¶
func NewUserDatabase(path string) (*UserDatabase, error)
NewUserDatabase creates a new UserDatabase at `path` or loads an existing one.
func (*UserDatabase) Add ¶
func (ub *UserDatabase) Add(name, password string, folders []string, rights []string) error
Add adds a new user to the database. If the user exists already, it is overwritten.
func (*UserDatabase) Close ¶
func (ub *UserDatabase) Close() error
Close cleans up all the resources used by a badger db.
func (*UserDatabase) Get ¶
func (ub *UserDatabase) Get(name string) (User, error)
Get returns a User, if it exists. If it does not exist, an error will be returned.
func (*UserDatabase) List ¶
func (ub *UserDatabase) List() ([]User, error)
List returns all users currently in the database.
func (*UserDatabase) Remove ¶
func (ub *UserDatabase) Remove(name string) error
Remove removes an existing user.