lib

package
v4.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultScope     = "/"
	DefaultModify    = false
	DefaultDebug     = false
	DefaultNoSniff   = false
	DefaultTLS       = false
	DefaultAuth      = false
	DefaultCert      = "cert.pem"
	DefaultKey       = "key.pem"
	DefaultAddress   = "0.0.0.0"
	DefaultPort      = 0
	DefaultPrefix    = "/"
	DefaultLogFormat = "console"
)

Variables

This section is empty.

Functions

func NewHandler added in v4.3.0

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

Types

type CORS added in v4.3.0

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 {
	Permissions `mapstructure:",squash"`
	Debug       bool
	Address     string
	Port        int
	TLS         bool
	Cert        string
	Key         string
	Prefix      string
	NoSniff     bool
	LogFormat   string `mapstructure:"log_format"`
	Auth        bool
	CORS        CORS
	Users       []User
}

func ParseConfig added in v4.3.0

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

func (*Config) Validate added in v4.3.0

func (c *Config) Validate() error

type Dir added in v4.3.0

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

func (Dir) OpenFile added in v4.3.0

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

func (Dir) Stat added in v4.3.0

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

type Handler added in v4.3.0

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

func (*Handler) ServeHTTP added in v4.3.0

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 Permissions added in v4.3.0

type Permissions struct {
	Scope  string
	Modify bool
	Rules  []*Rule
}

func (Permissions) Allowed added in v4.3.0

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

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

func (*Permissions) Validate added in v4.3.0

func (p *Permissions) Validate() error

type Rule

type Rule struct {
	Regex  bool
	Allow  bool
	Modify bool
	Path   string
	// TODO: remove Regex and replace by this. It encodes
	Regexp *regexp.Regexp `mapstructure:"-"`
}

func (*Rule) Matches added in v4.3.0

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

Matches checks if Rule matches the given path.

func (*Rule) Validate added in v4.3.0

func (r *Rule) Validate() error

type User

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

func (*User) Validate added in v4.3.0

func (u *User) Validate() error

Jump to

Keyboard shortcuts

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