update reva
This commit is contained in:
+48
-36
@@ -247,44 +247,56 @@ func checkIfNestedResource(ctx context.Context, ref *provider.Reference, parent
|
||||
parentPath := statResponse.Info.Path
|
||||
|
||||
childPath := ref.GetPath()
|
||||
if childPath == "" || childPath == "." {
|
||||
// We mint a token as the owner of the public share and try to stat the reference
|
||||
// TODO(ishank011): We need to find a better alternative to this
|
||||
|
||||
var user *userpb.User
|
||||
if statResponse.GetInfo().GetOwner().GetType() == userpb.UserType_USER_TYPE_SPACE_OWNER {
|
||||
// fake a space owner user
|
||||
user = &userpb.User{
|
||||
Id: statResponse.GetInfo().GetOwner(),
|
||||
}
|
||||
} else {
|
||||
userResp, err := client.GetUser(ctx, &userpb.GetUserRequest{UserId: statResponse.Info.Owner, SkipFetchingUserGroups: true})
|
||||
if err != nil || userResp.Status.Code != rpc.Code_CODE_OK {
|
||||
return false, err
|
||||
}
|
||||
user = userResp.User
|
||||
}
|
||||
|
||||
scope, err := scope.AddOwnerScope(map[string]*authpb.Scope{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
token, err := mgr.MintToken(ctx, user, scope)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
ctx = metadata.AppendToOutgoingContext(context.Background(), ctxpkg.TokenHeader, token)
|
||||
|
||||
childStat, err := client.Stat(ctx, &provider.StatRequest{Ref: ref})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if childStat.Status.Code != rpc.Code_CODE_OK {
|
||||
return false, statuspkg.NewErrorFromCode(childStat.Status.Code, "auth interceptor")
|
||||
}
|
||||
childPath = statResponse.Info.Path
|
||||
if childPath != "" && childPath != "." && strings.HasPrefix(childPath, parentPath) {
|
||||
// if the request is relative from the root, we can return directly
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// The request is not relative to the root. We need to find out if the requested resource is child of the `parent` (coming from token scope)
|
||||
// We mint a token as the owner of the public share and try to stat the reference
|
||||
// TODO(ishank011): We need to find a better alternative to this
|
||||
// NOTE: did somebody say service accounts? ...
|
||||
|
||||
var user *userpb.User
|
||||
if statResponse.GetInfo().GetOwner().GetType() == userpb.UserType_USER_TYPE_SPACE_OWNER {
|
||||
// fake a space owner user
|
||||
user = &userpb.User{
|
||||
Id: statResponse.GetInfo().GetOwner(),
|
||||
}
|
||||
} else {
|
||||
userResp, err := client.GetUser(ctx, &userpb.GetUserRequest{UserId: statResponse.Info.Owner, SkipFetchingUserGroups: true})
|
||||
if err != nil || userResp.Status.Code != rpc.Code_CODE_OK {
|
||||
return false, err
|
||||
}
|
||||
user = userResp.User
|
||||
}
|
||||
|
||||
scope, err := scope.AddOwnerScope(map[string]*authpb.Scope{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
token, err := mgr.MintToken(ctx, user, scope)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
ctx = metadata.AppendToOutgoingContext(context.Background(), ctxpkg.TokenHeader, token)
|
||||
|
||||
childStat, err := client.Stat(ctx, &provider.StatRequest{Ref: ref})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if childStat.Status.Code != rpc.Code_CODE_OK {
|
||||
return false, statuspkg.NewErrorFromCode(childStat.Status.Code, "auth interceptor")
|
||||
}
|
||||
pathResp, err := client.GetPath(ctx, &provider.GetPathRequest{ResourceId: childStat.GetInfo().GetId()})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if pathResp.Status.Code != rpc.Code_CODE_OK {
|
||||
return false, statuspkg.NewErrorFromCode(pathResp.Status.Code, "auth interceptor")
|
||||
}
|
||||
childPath = pathResp.Path
|
||||
|
||||
return strings.HasPrefix(childPath, parentPath), nil
|
||||
|
||||
}
|
||||
|
||||
Generated
Vendored
+13
@@ -1411,6 +1411,19 @@ func (h *Handler) createCs3Share(ctx context.Context, w http.ResponseWriter, r *
|
||||
}
|
||||
}
|
||||
|
||||
expiry := r.PostFormValue("expireDate")
|
||||
if expiry != "" {
|
||||
ts, err := time.Parse("2006-01-02T15:04:05-0700", expiry)
|
||||
if err != nil {
|
||||
return nil, &ocsError{
|
||||
Code: response.MetaBadRequest.StatusCode,
|
||||
Message: "could not parse expiry timestamp on this item",
|
||||
Error: err,
|
||||
}
|
||||
}
|
||||
req.Grant.Expiration = utils.TimeToTS(ts)
|
||||
}
|
||||
|
||||
createShareResponse, err := client.CreateShare(ctx, req)
|
||||
if err != nil {
|
||||
return nil, &ocsError{
|
||||
|
||||
Reference in New Issue
Block a user