lib

package
v5.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTLS     = false
	DefaultCert    = "cert.pem"
	DefaultKey     = "key.pem"
	DefaultAddress = "0.0.0.0"
	DefaultPort    = 6065
	DefaultPrefix  = "/"
)

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(c *Config) (http.Handler, error)

Types

type CORS

type CORS struct {
	Enabled        bool
	Credentials    bool
	AllowedHeaders []string `mapstructure:"allowed_headers"`
	AllowedHosts   []string `mapstructure:"allowed_hosts"`
	AllowedMethods []string `mapstructure:"allowed_methods"`
	ExposedHeaders []string `mapstructure:"exposed_headers"`
}

type Config

type Config struct {
	UserPermissions `mapstructure:",squash"`
	Debug           bool
	Address         string
	Port            int
	TLS             bool
	Cert            string
	Key             string
	Prefix          string
	NoSniff         bool
	NoPassword      bool
	BehindProxy     bool
	Log             Log
	CORS            CORS
	Users           []User
}

func ParseConfig

func ParseConfig(filename string, flags *pflag.FlagSet) (*Config, error)

func (*Config) GetLogger

func (cfg *Config) GetLogger() (*zap.Logger, error)

func (*Config) Validate

func (c *Config) Validate() error

type Dir

type Dir struct {
	webdav.Dir
	// contains filtered or unexported fields
}

func (Dir) OpenFile

func (d Dir) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error)

func (Dir) Stat

func (d Dir) Stat(ctx context.Context, name string) (os.FileInfo, error)

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP determines if the request is for this plugin, and if all prerequisites are met.

type Log

type Log struct {
	Format  string
	Colors  bool
	Outputs []string
}

type Permissions

type Permissions struct {
	Create bool
	Read   bool
	Update bool
	Delete bool
}

func (Permissions) Allowed

func (p Permissions) Allowed(r *http.Request, fileExists func(string) bool) bool

Allowed returns whether this permission set has permissions to execute this request in the source directory. This applies to all requests with all methods.

func (Permissions) AllowedDestination added in v5.2.0

func (p Permissions) AllowedDestination(r *http.Request, fileExists func(string) bool) bool

AllowedDestination returns whether this permissions set has permissions to execute this request in the destination directory. This only applies for COPY and MOVE requests.

func (*Permissions) UnmarshalText

func (p *Permissions) UnmarshalText(data []byte) error

type Rule

type Rule struct {
	Permissions Permissions
	Path        string
	Regex       *regexp.Regexp
}

func (*Rule) Matches

func (r *Rule) Matches(path string) bool

Matches checks if Rule matches the given path.

func (*Rule) Validate

func (r *Rule) Validate() error

type User

type User struct {
	UserPermissions `mapstructure:",squash"`
	Username        string
	Password        string
}

func (*User) Validate

func (u *User) Validate(noPassword bool) error

type UserPermissions

type UserPermissions struct {
	Directory   string
	Permissions Permissions
	Rules       []*Rule
}

func (UserPermissions) Allowed

func (p UserPermissions) Allowed(r *http.Request, fileExists func(string) bool) bool

Allowed checks if the user has permission to access a directory/file

func (*UserPermissions) Validate

func (p *UserPermissions) Validate() error

Jump to

Keyboard shortcuts

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