app

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Overview

Package app provides all app related stuff like config parsing, serving, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenHash added in v0.4.0

func GenHash(password []byte) string

GenHash generates a bcrypt hashed password string

func NewBasicAuthWebdavHandler

func NewBasicAuthWebdavHandler(a *App) http.Handler

NewBasicAuthWebdavHandler creates a new http handler with basic auth features. The handler will use the application config for user and password lookups.

Types

type App

type App struct {
	Config  *Config
	Handler *webdav.Handler
}

App holds configuration information and the webdav handler.

type AuthInfo added in v0.4.0

type AuthInfo struct {
	Username      string
	Authenticated bool
}

AuthInfo holds the username and authentication status

func AuthFromContext added in v0.4.0

func AuthFromContext(ctx context.Context) *AuthInfo

AuthFromContext returns information about the authentication state of the current user.

type Config

type Config struct {
	Address string
	Port    string
	Prefix  string
	Dir     string
	TLS     *TLS
	Log     Logging
	Realm   string
	Users   map[string]*UserInfo
	Cors    Cors
}

Config represents the configuration of the server application.

func ParseConfig

func ParseConfig(path string) *Config

ParseConfig parses the application configuration an sets defaults.

func (*Config) AuthenticationNeeded added in v0.4.0

func (cfg *Config) AuthenticationNeeded() bool

AuthenticationNeeded returns whether users are defined and authentication is required

type Cors added in v0.4.0

type Cors struct {
	Origin      string
	Credentials bool
}

Cors contains settings related to Cross-Origin Resource Sharing (CORS)

type Dir

type Dir struct {
	Config *Config
}

Dir is specialization of webdav.Dir with respect of an authenticated user to allow configuration access.

func (Dir) Mkdir

func (d Dir) Mkdir(ctx context.Context, name string, perm os.FileMode) error

Mkdir resolves the physical file and delegates this to an os.Mkdir execution

func (Dir) OpenFile

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

OpenFile resolves the physical file and delegates this to an os.OpenFile execution

func (Dir) RemoveAll

func (d Dir) RemoveAll(ctx context.Context, name string) error

RemoveAll resolves the physical file and delegates this to an os.RemoveAll execution

func (Dir) Rename

func (d Dir) Rename(ctx context.Context, oldName, newName string) error

Rename resolves the physical file and delegates this to an os.Rename execution

func (Dir) Stat

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

Stat resolves the physical file and delegates this to an os.Stat execution

type Logging added in v0.2.0

type Logging struct {
	Error  bool
	Create bool
	Read   bool
	Update bool
	Delete bool
}

Logging allows definition for logging each CRUD method.

type TLS

type TLS struct {
	CertFile string
	KeyFile  string
}

TLS allows specification of a certificate and private key file.

type UserInfo

type UserInfo struct {
	Password string
	Subdir   *string
}

UserInfo allows storing of a password and user directory.

Jump to

Keyboard shortcuts

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