5
5
[ ![ GoDoc] ( https://godoc.org/github.com/studio-b12/gowebdav?status.svg )] ( https://godoc.org/github.com/studio-b12/gowebdav )
6
6
[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/studio-b12/gowebdav )] ( https://goreportcard.com/report/github.com/studio-b12/gowebdav )
7
7
8
- A pure Golang WebDAV client library that comes with a reference implementation.
8
+ A pure Golang WebDAV client library that comes with a [ reference implementation] ( https://github.com/studio-b12/gowebdav/tree/master/cmd/gowebdav ) .
9
9
10
10
## Features at a glance
11
11
@@ -23,12 +23,13 @@ Our `gowebdav` library allows to perform following actions on the remote WebDAV
23
23
It also provides an [ authentication API] ( #type-authenticator ) that makes it easy to encapsulate and control complex authentication challenges.
24
24
The default implementation negotiates the algorithm based on the user's preferences and the methods offered by the remote server.
25
25
26
- Out-of-box support for:
26
+ Out-of-box authentication support for:
27
27
28
28
* [ BasicAuth] ( https://en.wikipedia.org/wiki/Basic_access_authentication )
29
29
* [ DigestAuth] ( https://en.wikipedia.org/wiki/Digest_access_authentication )
30
- * [ Kerberos comming] ( https://github.com/studio-b12/gowebdav/pull/71#issuecomment-1416465334 )
31
-
30
+ * [ MS-PASS] ( https://github.com/studio-b12/gowebdav/pull/70#issuecomment-1421713726 )
31
+ * [ WIP Kerberos] ( https://github.com/studio-b12/gowebdav/pull/71#issuecomment-1416465334 )
32
+ * [ WIP Bearer Token] ( https://github.com/studio-b12/gowebdav/issues/61 )
32
33
33
34
## Usage
34
35
@@ -189,6 +190,7 @@ included.
189
190
* [ type AuthFactory] ( #AuthFactory )
190
191
* [ type Authenticator] ( #Authenticator )
191
192
* [ func NewDigestAuth(login, secret string, rs * http.Response) (Authenticator, error)] ( #NewDigestAuth )
193
+ * [ func NewPassportAuth(c * http.Client, user, pw, partnerURL string, header * http.Header) (Authenticator, error)] ( #NewPassportAuth )
192
194
* [ type Authorizer] ( #Authorizer )
193
195
* [ func NewAutoAuth(login string, secret string) Authorizer] ( #NewAutoAuth )
194
196
* [ func NewEmptyAuth() Authorizer] ( #NewEmptyAuth )
@@ -238,14 +240,20 @@ included.
238
240
* [ func (f File) Size() int64] ( #File.Size )
239
241
* [ func (f File) String() string] ( #File.String )
240
242
* [ func (f File) Sys() interface{}] ( #File.Sys )
243
+ * [ type PassportAuth] ( #PassportAuth )
244
+ * [ func (p * PassportAuth) Authorize(c * http.Client, rq * http.Request, path string) error] ( #PassportAuth.Authorize )
245
+ * [ func (p * PassportAuth) Clone() Authenticator] ( #PassportAuth.Clone )
246
+ * [ func (p * PassportAuth) Close() error] ( #PassportAuth.Close )
247
+ * [ func (p * PassportAuth) String() string] ( #PassportAuth.String )
248
+ * [ func (p * PassportAuth) Verify(c * http.Client, rs * http.Response, path string) (redo bool, err error)] ( #PassportAuth.Verify )
241
249
* [ type StatusError] ( #StatusError )
242
250
* [ func (se StatusError) Error() string] ( #StatusError.Error )
243
251
244
252
##### <a name =" pkg-examples " >Examples</a >
245
253
* [ PathEscape] ( #example_PathEscape )
246
254
247
255
##### <a name =" pkg-files " >Package files</a >
248
- [ 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 )
256
+ [ 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 )
249
257
250
258
### <a name =" pkg-constants " >Constants</a >
251
259
``` go
@@ -382,6 +390,13 @@ func NewDigestAuth(login, secret string, rs *http.Response) (Authenticator, erro
382
390
```
383
391
NewDigestAuth creates a new instance of our Digest Authenticator
384
392
393
+ #### <a name="NewPassportAuth">func</a> [NewPassportAuth](https:// github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=386:495#L21)
394
+ ``` go
395
+ func NewPassportAuth(c *http.Client, user, pw, partnerURL string, header *http.Header) (Authenticator, error)
396
+ ```
397
+ constructor for PassportAuth creates a new PassportAuth object and
398
+ automatically authenticates against the given partnerURL
399
+
385
400
### <a name="Authorizer">type</a> [Authorizer](https:// github.com/studio-b12/gowebdav/blob/master/auth.go?s=349:764#L17)
386
401
``` go
387
402
type Authorizer interface {
@@ -407,7 +422,7 @@ based on the order of the registered Authenticators
407
422
and the remotely offered authentication methods.
408
423
First In, First Out.
409
424
410
- #### <a name="NewEmptyAuth">func</a> [NewEmptyAuth](https:// github.com/studio-b12/gowebdav/blob/master/auth.go?s=4486:4516#L128 )
425
+ #### <a name="NewEmptyAuth">func</a> [NewEmptyAuth](https:// github.com/studio-b12/gowebdav/blob/master/auth.go?s=4694:4724#L132 )
411
426
``` go
412
427
func NewEmptyAuth() Authorizer
413
428
```
@@ -416,7 +431,7 @@ The order of adding the Authenticator matters.
416
431
First In, First Out.
417
432
It offers the `NewAutoAuth` features.
418
433
419
- #### <a name="NewPreemptiveAuth">func</a> [NewPreemptiveAuth](https:// github.com/studio-b12/gowebdav/blob/master/auth.go?s=5092:5145#L144 )
434
+ #### <a name="NewPreemptiveAuth">func</a> [NewPreemptiveAuth](https:// github.com/studio-b12/gowebdav/blob/master/auth.go?s=5300:5353#L148 )
420
435
``` go
421
436
func NewPreemptiveAuth(auth Authenticator) Authorizer
422
437
```
@@ -497,25 +512,25 @@ func (c *Client) Connect() error
497
512
```
498
513
Connect connects to our dav server
499
514
500
- #### <a name="Client.Copy">func</a> (\*Client) [Copy](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=6804:6872 #L310)
515
+ #### <a name="Client.Copy">func</a> (\*Client) [Copy](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=6815:6883 #L310)
501
516
``` go
502
517
func (c *Client) Copy(oldpath, newpath string, overwrite bool) error
503
518
```
504
519
Copy copies a file from A to B
505
520
506
- #### <a name="Client.Mkdir">func</a> (\*Client) [Mkdir](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=5779:5841 #L259)
521
+ #### <a name="Client.Mkdir">func</a> (\*Client) [Mkdir](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=5790:5852 #L259)
507
522
``` go
508
523
func (c *Client) Mkdir(path string, _ os.FileMode) (err error)
509
524
```
510
525
Mkdir makes a directory
511
526
512
- #### <a name="Client.MkdirAll">func</a> (\*Client) [MkdirAll](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=6054:6119 #L273)
527
+ #### <a name="Client.MkdirAll">func</a> (\*Client) [MkdirAll](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=6065:6130 #L273)
513
528
``` go
514
529
func (c *Client) MkdirAll(path string, _ os.FileMode) (err error)
515
530
```
516
531
MkdirAll like mkdir -p, but for webdav
517
532
518
- #### <a name="Client.Read">func</a> (\*Client) [Read](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=6978:7028 #L315)
533
+ #### <a name="Client.Read">func</a> (\*Client) [Read](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=6989:7039 #L315)
519
534
``` go
520
535
func (c *Client) Read(path string) ([]byte, error)
521
536
```
@@ -527,13 +542,13 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error)
527
542
```
528
543
ReadDir reads the contents of a remote directory
529
544
530
- #### <a name="Client.ReadStream">func</a> (\*Client) [ReadStream](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=7339:7402 #L333)
545
+ #### <a name="Client.ReadStream">func</a> (\*Client) [ReadStream](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=7350:7413 #L333)
531
546
``` go
532
547
func (c *Client) ReadStream(path string) (io.ReadCloser, error)
533
548
```
534
549
ReadStream reads the stream for a given path
535
550
536
- #### <a name="Client.ReadStreamRange">func</a> (\*Client) [ReadStreamRange](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=8151:8241 #L355)
551
+ #### <a name="Client.ReadStreamRange">func</a> (\*Client) [ReadStreamRange](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=8162:8252 #L355)
537
552
``` go
538
553
func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadCloser, error)
539
554
```
@@ -546,19 +561,19 @@ If the server does not support partial content requests and returns full content
546
561
this function will emulate the behavior by skipping `offset` bytes and limiting the result
547
562
to `length`.
548
563
549
- #### <a name="Client.Remove">func</a> (\*Client) [Remove](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=5285:5327 #L236)
564
+ #### <a name="Client.Remove">func</a> (\*Client) [Remove](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=5296:5338 #L236)
550
565
``` go
551
566
func (c *Client) Remove(path string) error
552
567
```
553
568
Remove removes a remote file
554
569
555
- #### <a name="Client.RemoveAll">func</a> (\*Client) [RemoveAll](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=5393:5438 #L241)
570
+ #### <a name="Client.RemoveAll">func</a> (\*Client) [RemoveAll](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=5404:5449 #L241)
556
571
``` go
557
572
func (c *Client) RemoveAll(path string) error
558
573
```
559
574
RemoveAll removes remote files
560
575
561
- #### <a name="Client.Rename">func</a> (\*Client) [Rename](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=6638:6708 #L305)
576
+ #### <a name="Client.Rename">func</a> (\*Client) [Rename](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=6649:6719 #L305)
562
577
``` go
563
578
func (c *Client) Rename(oldpath, newpath string, overwrite bool) error
564
579
```
@@ -600,13 +615,13 @@ func (c *Client) Stat(path string) (os.FileInfo, error)
600
615
```
601
616
Stat returns the file stats for a specified path
602
617
603
- #### <a name="Client.Write">func</a> (\*Client) [Write](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=9261:9336 #L389)
618
+ #### <a name="Client.Write">func</a> (\*Client) [Write](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=9272:9347 #L389)
604
619
``` go
605
620
func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error)
606
621
```
607
622
Write writes data to a given path
608
623
609
- #### <a name="Client.WriteStream">func</a> (\*Client) [WriteStream](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=9760:9846 #L419)
624
+ #### <a name="Client.WriteStream">func</a> (\*Client) [WriteStream](https:// github.com/studio-b12/gowebdav/blob/master/client.go?s=9771:9857 #L419)
610
625
``` go
611
626
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) (err error)
612
627
```
@@ -720,6 +735,45 @@ func (f File) Sys() interface{}
720
735
```
721
736
Sys ????
722
737
738
+ ### <a name =" PassportAuth " >type</a > [ PassportAuth] ( https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=125:254#L12 )
739
+ ``` go
740
+ type PassportAuth struct {
741
+ // contains filtered or unexported fields
742
+ }
743
+
744
+ ```
745
+ PassportAuth structure holds our credentials
746
+
747
+ #### <a name =" PassportAuth.Authorize " >func</a > (\* PassportAuth) [ Authorize] ( https://github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=690:775#L32 )
748
+ ``` go
749
+ func (p *PassportAuth ) Authorize (c *http .Client , rq *http .Request , path string ) error
750
+ ```
751
+ Authorize the current request
752
+
753
+ #### <a name="PassportAuth.Clone">func</a> (\*PassportAuth) [Clone](https:// github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=1701:1745#L69)
754
+ ``` go
755
+ func (p *PassportAuth) Clone() Authenticator
756
+ ```
757
+ Clone creates a Copy of itself
758
+
759
+ #### <a name="PassportAuth.Close">func</a> (\*PassportAuth) [Close](https:// github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=1613:1649#L64)
760
+ ``` go
761
+ func (p *PassportAuth) Close() error
762
+ ```
763
+ Close cleans up all resources
764
+
765
+ #### <a name="PassportAuth.String">func</a> (\*PassportAuth) [String](https:// github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=2048:2086#L83)
766
+ ``` go
767
+ func (p *PassportAuth) String() string
768
+ ```
769
+ String toString
770
+
771
+ #### <a name="PassportAuth.Verify">func</a> (\*PassportAuth) [Verify](https:// github.com/studio-b12/gowebdav/blob/master/passportAuth.go?s=1075:1175#L46)
772
+ ``` go
773
+ func (p *PassportAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error)
774
+ ```
775
+ Verify verifies if the authentication is good
776
+
723
777
### <a name="StatusError">type</a> [StatusError](https:// github.com/studio-b12/gowebdav/blob/master/errors.go?s=499:538#L18)
724
778
``` go
725
779
type StatusError struct {
0 commit comments