ocdav

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrListingMembers     = "ERR_LISTING_MEMBERS_NOT_ALLOWED"
	ErrInvalidCredentials = "ERR_INVALID_CREDENTIALS"
	ErrMissingBasicAuth   = "ERR_MISSING_BASIC_AUTH"
	// ErrMissingBearerAuth  = "ERR_MISSING_BEARER_AUTH"
	ErrFileNotFoundInRoot = "ERR_FILE_NOT_FOUND_IN_ROOT"
)
View Source
const (

	// SabredavBadRequest maps to HTTP 400.
	SabredavBadRequest code = iota
	// SabredavMethodNotAllowed maps to HTTP 405.
	SabredavMethodNotAllowed
	// SabredavNotAuthenticated maps to HTTP 401.
	SabredavNotAuthenticated
	// SabredavPreconditionFailed maps to HTTP 412.
	SabredavPreconditionFailed
	// SabredavPermissionDenied maps to HTTP 403.
	SabredavPermissionDenied
	// SabredavNotFound maps to HTTP 404.
	SabredavNotFound
	// SabredavConflict maps to HTTP 409.
	SabredavConflict
)
View Source
const (
	MethodPropfind  = "PROPFIND"
	MethodLock      = "LOCK"
	MethodUnlock    = "UNLOCK"
	MethodProppatch = "PROPPATCH"
	MethodMkcol     = "MKCOL"
	MethodMove      = "MOVE"
	MethodCopy      = "COPY"
	MethodReport    = "REPORT"
)

Common Webdav methods.

Unless otherwise noted, these are defined in RFC 4918 section 9.

View Source
const (
	HeaderAcceptRanges               = "Accept-Ranges"
	HeaderAccessControlAllowHeaders  = "Access-Control-Allow-Headers"
	HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers"
	HeaderContentDisposistion        = "Content-Disposition"
	HeaderContentLength              = "Content-Length"
	HeaderContentRange               = "Content-Range"
	HeaderContentType                = "Content-Type"
	HeaderETag                       = "ETag"
	HeaderLastModified               = "Last-Modified"
	HeaderLocation                   = "Location"
	HeaderRange                      = "Range"
	HeaderIfMatch                    = "If-Match"
	HeaderChecksum                   = "Digest"
)

Common HTTP headers.

View Source
const (
	HeaderOCFileID             = "OC-FileId"
	HeaderOCETag               = "OC-ETag"
	HeaderOCChecksum           = "OC-Checksum"
	HeaderOCPermissions        = "OC-Perm"
	HeaderDepth                = "Depth"
	HeaderDav                  = "DAV"
	HeaderTusResumable         = "Tus-Resumable"
	HeaderTusVersion           = "Tus-Version"
	HeaderTusExtension         = "Tus-Extension"
	HeaderTusChecksumAlgorithm = "Tus-Checksum-Algorithm"
	HeaderTusUploadExpires     = "Upload-Expires"
	HeaderDestination          = "Destination"
	HeaderOverwrite            = "Overwrite"
	HeaderUploadChecksum       = "Upload-Checksum"
	HeaderUploadLength         = "Upload-Length"
	HeaderUploadMetadata       = "Upload-Metadata"
	HeaderUploadOffset         = "Upload-Offset"
	HeaderOCMtime              = "X-OC-Mtime"
	HeaderExpectedEntityLength = "X-Expected-Entity-Length"
	HeaderTransferAuth         = "TransferHeaderAuthorization"
	HeaderLockID               = "X-Lock-Id"
	HeaderLockHolder           = "X-Lock-Holder"
	HeaderDisableVersioning    = "X-Disable-Versioning"
)

Non standard HTTP headers.

View Source
const (
	// PerfMarkerResponseTime corresponds to the interval at which a performance marker is sent back to the TPC client.
	PerfMarkerResponseTime float64 = 5
)
View Source
const (

	// RFC1123 time that mimics oc10. time.RFC1123 would end in "UTC", see https://github.com/golang/go/issues/13781
	RFC1123 = "Mon, 02 Jan 2006 15:04:05 GMT"
)

Variables

This section is empty.

Functions

func HandleErrorStatus

func HandleErrorStatus(log *zerolog.Logger, w http.ResponseWriter, s *rpc.Status)

HandleErrorStatus checks the status code, logs a Debug or Error level message and writes an appropriate http status.

func HandleWebdavError

func HandleWebdavError(log *zerolog.Logger, w http.ResponseWriter, b []byte, err error)

HandleWebdavError checks the status code, logs an error and creates a webdav response body if needed.

func Marshal

func Marshal(e exception, errorCode string) ([]byte, error)

Marshal just calls the xml marshaller for a given exception.

func New

func New(ctx context.Context, m map[string]interface{}) (global.Service, error)

New returns a new ocdav.

Types

type AvatarsHandler

type AvatarsHandler struct {
}

AvatarsHandler handles avatar requests.

func (*AvatarsHandler) Handler

func (h *AvatarsHandler) Handler(s *svc) http.Handler

Handler handles requests.

type Config

type Config struct {
	Prefix string `mapstructure:"prefix"`
	// FilesNamespace prefixes the namespace, optionally with user information.
	// Example: if FilesNamespace is /users/{{substr 0 1 .Username}}/{{.Username}}
	// and received path is /docs the internal path will be:
	// /users/<first char of username>/<username>/docs
	FilesNamespace string `mapstructure:"files_namespace"`
	// WebdavNamespace prefixes the namespace, optionally with user information.
	// Example: if WebdavNamespace is /users/{{substr 0 1 .Username}}/{{.Username}}
	// and received path is /docs the internal path will be:
	// /users/<first char of username>/<username>/docs
	WebdavNamespace string `mapstructure:"webdav_namespace"`
	OCMNamespace    string `mapstructure:"ocm_namespace"`
	GatewaySvc      string `mapstructure:"gatewaysvc"`
	Timeout         int64  `mapstructure:"timeout"`
	Insecure        bool   `docs:"false;Whether to skip certificate checks when sending requests." mapstructure:"insecure"`
	// If true, HTTP COPY will expect the HTTP-TPC (third-party copy) headers
	EnableHTTPTpc bool `mapstructure:"enable_http_tpc"`
	// The authentication scheme to use for the tpc push call when userinfo part is specified in the Destination header uri. Default value is 'bearer'.
	// Possible values:
	// "bearer"				results in header: Authorization: Bearer ...token...
	// "x-access-token":	results in header: X-Access-Token: ...token...
	HTTPTpcPushAuthHeader        string                            `mapstructure:"http_tpc_push_auth_header"`
	PublicURL                    string                            `mapstructure:"public_url"`
	FavoriteStorageDriver        string                            `mapstructure:"favorite_storage_driver"`
	FavoriteStorageDrivers       map[string]map[string]interface{} `mapstructure:"favorite_storage_drivers"`
	PublicLinkDownload           *ConfigPublicLinkDownload         `mapstructure:"publiclink_download"`
	DisabledOpenInAppPaths       []string                          `mapstructure:"disabled_open_in_app_paths"`
	Notifications                map[string]interface{}            `docs:"nil; settings for the notification helper" mapstructure:"notifications"`
	MyOfficeFilesAllowedProjects []string                          `mapstructure:"my_office_files_projects"`
	SpacesEnabled                bool                              `mapstructure:"spaces_enabled"`
}

Config holds the config options that need to be passed down to all ocdav handlers.

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

type ConfigPublicLinkDownload

type ConfigPublicLinkDownload struct {
	MaxNumFiles  int64  `mapstructure:"max_num_files"`
	MaxSize      int64  `mapstructure:"max_size"`
	PublicFolder string `mapstructure:"public_folder"`
}

type DavHandler

type DavHandler struct {
	AvatarsHandler      *AvatarsHandler
	FilesHandler        *WebDavHandler
	FilesHomeHandler    *WebDavHandler
	MetaHandler         *MetaHandler
	TrashbinHandler     *TrashbinHandler
	SpacesHandler       *WebDavHandler
	PublicFolderHandler *WebDavHandler
	PublicFileHandler   *PublicFileHandler
	OCMSharesHandler    *WebDavHandler
}

DavHandler routes to the different sub handlers.

func (*DavHandler) Handler

func (h *DavHandler) Handler(s *svc) http.Handler

Handler handles requests.

type MetaHandler

type MetaHandler struct {
	VersionsHandler *VersionsHandler
}

MetaHandler handles meta requests.

func (*MetaHandler) Handler

func (h *MetaHandler) Handler(s *svc) http.Handler

Handler handles requests.

type PerfResponse

type PerfResponse struct {
	Timestamp time.Time
	Bytes     uint64
	Index     int
	Count     int
}

PerfResponse provides a single chunk of permormance marker response.

type Proppatch

type Proppatch struct {
	// Remove specifies whether this patch removes properties. If it does not
	// remove them, it sets them.
	Remove bool
	// Props contains the properties to be set or removed.
	Props []propertyXML
}

Proppatch describes a property update instruction as defined in RFC 4918. See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH

type PublicFileHandler

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

PublicFileHandler handles requests on a shared file. it needs to be wrapped in a collection.

func (*PublicFileHandler) Handler

func (h *PublicFileHandler) Handler(s *svc) http.Handler

Handler handles requests.

type SpacesHandler

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

SpacesHandler handles trashbin requests.

func (*SpacesHandler) Handler

func (h *SpacesHandler) Handler(s *svc) http.Handler

Handler handles requests.

type TrashbinHandler

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

TrashbinHandler handles trashbin requests.

func (*TrashbinHandler) Handler

func (h *TrashbinHandler) Handler(s *svc) http.Handler

Handler handles requests.

type VersionsHandler

type VersionsHandler struct{}

VersionsHandler handles version requests.

func (*VersionsHandler) Handler

func (h *VersionsHandler) Handler(s *svc, rid *provider.ResourceId) http.Handler

Handler handles requests versions can be listed with a PROPFIND to /remote.php/dav/meta/<fileid>/v a version is identified by a timestamp, eg. /remote.php/dav/meta/<fileid>/v/1561410426.

type WebDavHandler

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

WebDavHandler implements a dav endpoint.

func (*WebDavHandler) Handler

func (h *WebDavHandler) Handler(s *svc) http.Handler

Handler handles requests.

type WriteCounter

type WriteCounter struct {
	Total    uint64
	PrevTime time.Time
	// contains filtered or unexported fields
}

WriteCounter counts the number of bytes transferred and reports back to the TPC client about the progress of the transfer through the performance marker response stream.

func (*WriteCounter) SendPerfMarker

func (wc *WriteCounter) SendPerfMarker(size uint64)

SendPerfMarker flushes a single chunk (performance marker) as part of the chunked transfer encoding scheme.

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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