Skip to content

Commit

Permalink
fix publicshare
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed May 25, 2021
1 parent 4af4a25 commit 8eac1b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/grpc/interceptors/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func dismantleToken(ctx context.Context, tkn string, req interface{}, mgr token.
}
}

return nil, err
return nil, errtypes.PermissionDenied("access token has invalid scope")
}

func extractRef(req interface{}) (*provider.Reference, bool) {
Expand Down
7 changes: 5 additions & 2 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,10 @@ func (s *svc) getPath(ctx context.Context, ref *provider.Reference, keys ...stri
return res.Info.Ref.Path, res.Status
}

return ref.Path, &rpc.Status{Code: rpc.Code_CODE_OK}
if ref.Path != "" {
return ref.Path, &rpc.Status{Code: rpc.Code_CODE_OK}
}
return "", &rpc.Status{Code: rpc.Code_CODE_INTERNAL}
}

// /home/MyShares/
Expand Down Expand Up @@ -1920,7 +1923,7 @@ func (s *svc) findProviders(ctx context.Context, ref *provider.Reference) ([]*re
})

if err != nil {
return nil, errors.Wrap(err, "gateway: error calling GetStorageProvider")
return nil, errors.Wrap(err, "gateway: error calling GetStorageProviders")
}

if res.Status.Code != rpc.Code_CODE_OK {
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (s *svc) handlePropfindOnToken(w http.ResponseWriter, r *http.Request, ns s

// find actual file name
pathRes, err := client.GetPath(ctx, &provider.GetPathRequest{
Ref: tokenStatInfo.GetRef(),
Ref: tokenStatInfo.GetId(),
})
if err != nil {
sublog.Warn().Msg("Could not get path of resource")
Expand Down
3 changes: 2 additions & 1 deletion pkg/auth/scope/publicshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ func publicshareScope(scope *authpb.Scope, resource interface{}) (bool, error) {

func checkStorageRef(s *link.PublicShare, r *provider.Reference) bool {
// ref: <id:<storage_id:$storageID opaque_id:$opaqueID > >
if r != nil {
if r.StorageId != "" || r.NodeId != "" {
return s.Ref.StorageId == r.StorageId && s.Ref.NodeId == r.NodeId
}

// ref: <path:"/public/$token" >
if strings.HasPrefix(r.GetPath(), "/public/"+s.Token) {
return true
Expand Down

0 comments on commit 8eac1b8

Please sign in to comment.