config

package
v0.1.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileName = "browsefile.json"

Functions

func GetAllowedShares

func GetAllowedShares(user string, excludeSelf bool) (res map[string][]*AllowedShare)

filter out allowed shares, and returns modified path, starting with username

func GetShare

func GetShare(ru, su, reqPath string) (res *ShareItem, user *UserConfig)

* ru is request user

Types

type AllowedShare

type AllowedShare struct {
	*UserConfig
	*ShareItem
}

type Auth

type Auth struct {
	// Define if which of the following authentication mechansims should be used:
	// - 'default', which requires a user and a password.
	// - 'proxy', which requires a valid user and the user name has to be provided through an
	//   web header.
	// - 'none', which allows anyone to access the filebrowser instance.
	Method string `json:"method"`
	// If 'Method' is set to 'proxy' the header configured below is used to identify the user.
	Header string `json:"header"`

	Key string `json:"key"`
}

Auth settings.

func (*Auth) CopyAuth

func (auth *Auth) CopyAuth() *Auth

type CaptchaConfig

type CaptchaConfig struct {
	Host   string `json:"host"`
	Key    string `json:"key"`
	Secret string `json:"secret"`
}

func (*CaptchaConfig) CopyCaptchaConfig

func (c *CaptchaConfig) CopyCaptchaConfig() *CaptchaConfig

type GlobalConfig

type GlobalConfig struct {
	Users          []*UserConfig `json:"users"`
	Port           int           `json:"port"`
	IP             string        `json:"ip"`
	Log            string        `json:"log"`
	BaseUrl        string        `json:"baseUrl"`
	PrefixUrl      string        `json:"prefixUrl"`
	RefreshSeconds int           `json:"configRamRefreshSeconds"`
	TLSKey         string        `json:"tlsKey"`
	TLSCert        string        `json:"tlsCert"`
	*CaptchaConfig `json:"captchaConfig"`
	*Auth          `json:"auth"`
	*PreviewConf   `json:"preview"`
	// contains filtered or unexported fields
}

Single config for everything. update automatically

func (*GlobalConfig) Add

func (cfg *GlobalConfig) Add(u *UserConfig) error

func (*GlobalConfig) CopyConfig

func (cfg *GlobalConfig) CopyConfig() (res *GlobalConfig)

func (*GlobalConfig) Delete

func (cfg *GlobalConfig) Delete(username string) error

func (*GlobalConfig) GetAdmin

func (cfg *GlobalConfig) GetAdmin() *UserConfig

func (*GlobalConfig) GetByIp

func (cfg *GlobalConfig) GetByIp(ip string) (*UserConfig, bool)

func (*GlobalConfig) GetByUsername

func (cfg *GlobalConfig) GetByUsername(username string) (*UserConfig, bool)

func (*GlobalConfig) GetKeyBytes

func (cfg *GlobalConfig) GetKeyBytes() ([]byte, error)

func (*GlobalConfig) GetUsers

func (cfg *GlobalConfig) GetUsers() (res []*UserConfig)

func (*GlobalConfig) Init added in v0.1.4

func (cfg *GlobalConfig) Init()

func (*GlobalConfig) ReadConfigFile

func (cfg *GlobalConfig) ReadConfigFile(file string)

func (*GlobalConfig) SetKey

func (cfg *GlobalConfig) SetKey(k []byte)

func (*GlobalConfig) SetupLog

func (cfg *GlobalConfig) SetupLog()

func (*GlobalConfig) StartMonitor

func (cfg *GlobalConfig) StartMonitor()

func (*GlobalConfig) Store

func (cfg *GlobalConfig) Store()

indicate that changes made

func (*GlobalConfig) Update

func (cfg *GlobalConfig) Update(u *UserConfig) error

func (*GlobalConfig) UpdateConfig

func (cfg *GlobalConfig) UpdateConfig(u *GlobalConfig)

func (*GlobalConfig) UpdateUsers

func (cfg *GlobalConfig) UpdateUsers(users []*UserConfig) error

func (*GlobalConfig) Verify

func (cfg *GlobalConfig) Verify()

type PreviewConf

type PreviewConf struct {
	//enable preview generating by call .sh
	AllowGeneratePreview bool `json:"allowGeneratePreview"`
	Threads              int  `json:"threads"`
	FirstRun             bool `json:"firstRun"`
}

Auth settings.

type ShareItem

type ShareItem struct {
	Path string `json:"path"`
	//allow all not registered
	AllowExternal bool `json:"allowExternal"`
	//allow all registered users
	AllowLocal bool `json:"allowLocal"`
	//allowed by only specific users
	AllowUsers []string `json:"allowedUsers"`
}

presents 1 share path in filesystem, and access rules

func (*ShareItem) IsActive

func (shr *ShareItem) IsActive() (res bool)

func (*ShareItem) IsAllowed

func (shr *ShareItem) IsAllowed(user string) (res bool)

type UserConfig

type UserConfig struct {
	FirstRun bool `json:"firstRun"`
	// Tells if this user is an admin.
	Admin bool `json:"admin"`
	// These indicate if the user can perform certain actions.
	AllowEdit bool `json:"allowEdit"` // Edit/rename files
	AllowNew  bool `json:"allowNew"`  // Create files and folders

	// Prevents the user to change its password.
	LockPassword bool `json:"lockPassword"`

	// Locale is the language of the user.
	Locale string `json:"locale"`

	// The hashed password. This never reaches the front-end because it's temporarily
	// emptied during JSON marshall.
	Password string `json:"password"`

	// Scope is the path the user has access to.
	Scope string `json:"homePath"`

	// Username is the user username used to login.
	Username string `json:"username" storm:"index,unique"`

	// User view mode for files and folders.
	ViewMode string `json:"viewMode"`
	// system path to store user's image/video previews
	PreviewScope string `json:"previewPath"`

	Shares []*ShareItem `json:"shares"`
	//authenticate by IP, need to change auth.method
	IpAuth []string `json:"ipAuth"`

	//create files/folders according this ownership
	UID int `json:"uid"`
	GID int `json:"gid"`
}

User contains the configuration for each user.

func (*UserConfig) AddShare

func (u *UserConfig) AddShare(shr *ShareItem) (res bool)

func (*UserConfig) DeleteShare

func (u *UserConfig) DeleteShare(relPath string) (res bool)

func (*UserConfig) GetShare

func (u *UserConfig) GetShare(relPath string) (res *ShareItem)

Jump to

Keyboard shortcuts

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