diff --git a/README.md b/README.md index 0e4e804..5355bdb 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GoDoc](https://godoc.org/github.com/studio-b12/gowebdav?status.svg)](https://godoc.org/github.com/studio-b12/gowebdav) [![Go Report Card](https://goreportcard.com/badge/github.com/studio-b12/gowebdav)](https://goreportcard.com/report/github.com/studio-b12/gowebdav) -A pure Golang WebDAV client library that comes with a reference implementation. +A pure Golang WebDAV client library that comes with a [reference implementation](https://github.com/studio-b12/gowebdav/tree/master/cmd/gowebdav). ## Features at a glance @@ -23,12 +23,13 @@ Our `gowebdav` library allows to perform following actions on the remote WebDAV It also provides an [authentication API](#type-authenticator) that makes it easy to encapsulate and control complex authentication challenges. The default implementation negotiates the algorithm based on the user's preferences and the methods offered by the remote server. -Out-of-box support for: +Out-of-box authentication support for: * [BasicAuth](https://en.wikipedia.org/wiki/Basic_access_authentication) * [DigestAuth](https://en.wikipedia.org/wiki/Digest_access_authentication) -* [Kerberos comming](https://github.com/studio-b12/gowebdav/pull/71#issuecomment-1416465334) - +* [MS-PASS](https://github.com/studio-b12/gowebdav/pull/70#issuecomment-1421713726) +* [WIP Kerberos](https://github.com/studio-b12/gowebdav/pull/71#issuecomment-1416465334) +* [WIP Bearer Token](https://github.com/studio-b12/gowebdav/issues/61) ## Usage @@ -189,6 +190,7 @@ included. * [type AuthFactory](#AuthFactory) * [type Authenticator](#Authenticator) * [func NewDigestAuth(login, secret string, rs *http.Response) (Authenticator, error)](#NewDigestAuth) + * [func NewPassportAuth(c *http.Client, user, pw, partnerURL string, header *http.Header) (Authenticator, error)](#NewPassportAuth) * [type Authorizer](#Authorizer) * [func NewAutoAuth(login string, secret string) Authorizer](#NewAutoAuth) * [func NewEmptyAuth() Authorizer](#NewEmptyAuth) @@ -238,6 +240,12 @@ included. * [func (f File) Size() int64](#File.Size) * [func (f File) String() string](#File.String) * [func (f File) Sys() interface{}](#File.Sys) +* [type PassportAuth](#PassportAuth) + * [func (p *PassportAuth) Authorize(c *http.Client, rq *http.Request, path string) error](#PassportAuth.Authorize) + * [func (p *PassportAuth) Clone() Authenticator](#PassportAuth.Clone) + * [func (p *PassportAuth) Close() error](#PassportAuth.Close) + * [func (p *PassportAuth) String() string](#PassportAuth.String) + * [func (p *PassportAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error)](#PassportAuth.Verify) * [type StatusError](#StatusError) * [func (se StatusError) Error() string](#StatusError.Error) @@ -245,7 +253,7 @@ included. * [PathEscape](#example_PathEscape) ##### Package files -[auth.go](https://github.com/studio-b12/gowebdav/blob/master/auth.go) [basicAuth.go](https://github.com/studio-b12/gowebdav/blob/master/basicAuth.go) [client.go](https://github.com/studio-b12/gowebdav/blob/master/client.go) [digestAuth.go](https://github.com/studio-b12/gowebdav/blob/master/digestAuth.go) [doc.go](https://github.com/studio-b12/gowebdav/blob/master/doc.go) [errors.go](https://github.com/studio-b12/gowebdav/blob/master/errors.go) [file.go](https://github.com/studio-b12/gowebdav/blob/master/file.go) [netrc.go](https://github.com/studio-b12/gowebdav/blob/master/netrc.go) [requests.go](https://github.com/studio-b12/gowebdav/blob/master/requests.go) [utils.go](https://github.com/studio-b12/gowebdav/blob/master/utils.go) +[auth.go](https://github.com/studio-b12/gowebdav/blob/master/auth.go) [basicAuth.go](https://github.com/studio-b12/gowebdav/blob/master/basicAuth.go) [client.go](https://github.com/studio-b12/gowebdav/blob/master/client.go) [digestAuth.go](https://github.com/studio-b12/gowebdav/blob/master/digestAuth.go) [doc.go](https://github.com/studio-b12/gowebdav/blob/master/doc.go) [errors.go](https://github.com/studio-b12/gowebdav/blob/master/errors.go) [file.go](https://github.com/studio-b12/gowebdav/blob/master/file.go) [netrc.go](https://github.com/studio-b12/gowebdav/blob/master/netrc.go) [passportAuth.go](https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go) [requests.go](https://github.com/studio-b12/gowebdav/blob/master/requests.go) [utils.go](https://github.com/studio-b12/gowebdav/blob/master/utils.go) ### Constants ``` go @@ -382,6 +390,13 @@ func NewDigestAuth(login, secret string, rs *http.Response) (Authenticator, erro ``` NewDigestAuth creates a new instance of our Digest Authenticator +#### func [NewPassportAuth](https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=386:495#L21) +``` go +func NewPassportAuth(c *http.Client, user, pw, partnerURL string, header *http.Header) (Authenticator, error) +``` +constructor for PassportAuth creates a new PassportAuth object and +automatically authenticates against the given partnerURL + ### type [Authorizer](https://github.com/studio-b12/gowebdav/blob/master/auth.go?s=349:764#L17) ``` go type Authorizer interface { @@ -407,7 +422,7 @@ based on the order of the registered Authenticators and the remotely offered authentication methods. First In, First Out. -#### func [NewEmptyAuth](https://github.com/studio-b12/gowebdav/blob/master/auth.go?s=4486:4516#L128) +#### func [NewEmptyAuth](https://github.com/studio-b12/gowebdav/blob/master/auth.go?s=4694:4724#L132) ``` go func NewEmptyAuth() Authorizer ``` @@ -416,7 +431,7 @@ The order of adding the Authenticator matters. First In, First Out. It offers the `NewAutoAuth` features. -#### func [NewPreemptiveAuth](https://github.com/studio-b12/gowebdav/blob/master/auth.go?s=5092:5145#L144) +#### func [NewPreemptiveAuth](https://github.com/studio-b12/gowebdav/blob/master/auth.go?s=5300:5353#L148) ``` go func NewPreemptiveAuth(auth Authenticator) Authorizer ``` @@ -497,25 +512,25 @@ func (c *Client) Connect() error ``` Connect connects to our dav server -#### func (\*Client) [Copy](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6804:6872#L310) +#### func (\*Client) [Copy](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6815:6883#L310) ``` go func (c *Client) Copy(oldpath, newpath string, overwrite bool) error ``` Copy copies a file from A to B -#### func (\*Client) [Mkdir](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5779:5841#L259) +#### func (\*Client) [Mkdir](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5790:5852#L259) ``` go func (c *Client) Mkdir(path string, _ os.FileMode) (err error) ``` Mkdir makes a directory -#### func (\*Client) [MkdirAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6054:6119#L273) +#### func (\*Client) [MkdirAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6065:6130#L273) ``` go func (c *Client) MkdirAll(path string, _ os.FileMode) (err error) ``` MkdirAll like mkdir -p, but for webdav -#### func (\*Client) [Read](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6978:7028#L315) +#### func (\*Client) [Read](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6989:7039#L315) ``` go func (c *Client) Read(path string) ([]byte, error) ``` @@ -527,13 +542,13 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) ``` ReadDir reads the contents of a remote directory -#### func (\*Client) [ReadStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7339:7402#L333) +#### func (\*Client) [ReadStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7350:7413#L333) ``` go func (c *Client) ReadStream(path string) (io.ReadCloser, error) ``` ReadStream reads the stream for a given path -#### func (\*Client) [ReadStreamRange](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=8151:8241#L355) +#### func (\*Client) [ReadStreamRange](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=8162:8252#L355) ``` go func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadCloser, error) ``` @@ -546,19 +561,19 @@ If the server does not support partial content requests and returns full content this function will emulate the behavior by skipping `offset` bytes and limiting the result to `length`. -#### func (\*Client) [Remove](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5285:5327#L236) +#### func (\*Client) [Remove](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5296:5338#L236) ``` go func (c *Client) Remove(path string) error ``` Remove removes a remote file -#### func (\*Client) [RemoveAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5393:5438#L241) +#### func (\*Client) [RemoveAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5404:5449#L241) ``` go func (c *Client) RemoveAll(path string) error ``` RemoveAll removes remote files -#### func (\*Client) [Rename](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6638:6708#L305) +#### func (\*Client) [Rename](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6649:6719#L305) ``` go func (c *Client) Rename(oldpath, newpath string, overwrite bool) error ``` @@ -600,13 +615,13 @@ func (c *Client) Stat(path string) (os.FileInfo, error) ``` Stat returns the file stats for a specified path -#### func (\*Client) [Write](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=9261:9336#L389) +#### func (\*Client) [Write](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=9272:9347#L389) ``` go func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error) ``` Write writes data to a given path -#### func (\*Client) [WriteStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=9760:9846#L419) +#### func (\*Client) [WriteStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=9771:9857#L419) ``` go func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) (err error) ``` @@ -720,6 +735,45 @@ func (f File) Sys() interface{} ``` Sys ???? +### type [PassportAuth](https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=125:254#L12) +``` go +type PassportAuth struct { + // contains filtered or unexported fields +} + +``` +PassportAuth structure holds our credentials + +#### func (\*PassportAuth) [Authorize](https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=690:775#L32) +``` go +func (p *PassportAuth) Authorize(c *http.Client, rq *http.Request, path string) error +``` +Authorize the current request + +#### func (\*PassportAuth) [Clone](https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=1701:1745#L69) +``` go +func (p *PassportAuth) Clone() Authenticator +``` +Clone creates a Copy of itself + +#### func (\*PassportAuth) [Close](https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=1613:1649#L64) +``` go +func (p *PassportAuth) Close() error +``` +Close cleans up all resources + +#### func (\*PassportAuth) [String](https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=2048:2086#L83) +``` go +func (p *PassportAuth) String() string +``` +String toString + +#### func (\*PassportAuth) [Verify](https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=1075:1175#L46) +``` go +func (p *PassportAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error) +``` +Verify verifies if the authentication is good + ### type [StatusError](https://github.com/studio-b12/gowebdav/blob/master/errors.go?s=499:538#L18) ``` go type StatusError struct {