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

File share manager #505

Merged
merged 9 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/gogo/protobuf v1.2.0 // indirect
github.com/golang/protobuf v1.3.3
github.com/gomodule/redigo v2.0.0+incompatible
github.com/google/uuid v1.1.1
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4
github.com/jedib0t/go-pretty v4.3.0+incompatible
github.com/mattn/go-colorable v0.0.9 // indirect
Expand All @@ -30,15 +31,13 @@ require (
github.com/rs/zerolog v1.17.2
go.opencensus.io v0.22.3
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
google.golang.org/grpc v1.27.1
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.27 // indirect
gopkg.in/ldap.v2 v2.5.1
gopkg.in/square/go-jose.v2 v2.2.2 // indirect
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect
)

go 1.13
11 changes: 9 additions & 2 deletions internal/grpc/services/usershareprovider/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/cs3org/reva/pkg/rgrpc/status"
"github.com/cs3org/reva/pkg/share"
"github.com/cs3org/reva/pkg/share/manager/registry"
"github.com/cs3org/reva/pkg/user"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"google.golang.org/grpc"
Expand Down Expand Up @@ -84,6 +85,11 @@ func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
return nil, err
}

// if driver is empty we default to json
if c.Driver == "" {
c.Driver = "json"
}

sm, err := getShareManager(c)
if err != nil {
return nil, err
Expand All @@ -98,10 +104,11 @@ func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
}

func (s *service) CreateShare(ctx context.Context, req *collaboration.CreateShareRequest) (*collaboration.CreateShareResponse, error) {
u := user.ContextMustGetUser(ctx)
// TODO(labkode): validate input
// TODO(labkode): hack: use configured IDP or use hostname as default.
if req.Grant.Grantee.Id.Idp == "" {
req.Grant.Grantee.Id.Idp = "localhost"
// use logged in user Idp as default.
req.Grant.Grantee.Id.Idp = u.Id.Idp
}
share, err := s.sm.Share(ctx, req.ResourceInfo, req.Grant)
if err != nil {
Expand Down