Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transfer token in webdav copy #888

Merged
merged 1 commit into from
Jun 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions internal/http/services/owncloud/ocdav/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/internal/http/services/datagateway"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp"
tokenpkg "github.com/cs3org/reva/pkg/token"
Expand Down Expand Up @@ -271,6 +272,7 @@ func descend(ctx context.Context, client gateway.GatewayAPIClient, src *provider
if err != nil {
return err
}
httpDownloadReq.Header.Set(datagateway.TokenTransportHeader, dRes.Token)

httpDownloadClient := rhttp.GetHTTPClient(ctx)

Expand All @@ -285,15 +287,15 @@ func descend(ctx context.Context, client gateway.GatewayAPIClient, src *provider
}

// do upload
err = tusUpload(ctx, uRes.UploadEndpoint, dst, httpDownloadRes.Body, src.GetSize())
err = tusUpload(ctx, uRes.UploadEndpoint, uRes.Token, dst, httpDownloadRes.Body, src.GetSize())
if err != nil {
return err
}
}
return nil
}

func tusUpload(ctx context.Context, dataServerURL string, fn string, body io.Reader, length uint64) error {
func tusUpload(ctx context.Context, dataServerURL string, transferToken string, fn string, body io.Reader, length uint64) error {
var err error
log := appctx.GetLogger(ctx)

Expand All @@ -311,6 +313,7 @@ func tusUpload(ctx context.Context, dataServerURL string, fn string, body io.Rea
Str("token", tokenpkg.ContextMustGetToken(ctx)).
Msg("adding token to header")
c.Header.Set(tokenpkg.TokenHeader, tokenpkg.ContextMustGetToken(ctx))
c.Header.Set(datagateway.TokenTransportHeader, transferToken)

tusc, err := tus.NewClient(dataServerURL, c)
if err != nil {
Expand Down