Skip to content

Commit

Permalink
add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Dec 5, 2023
1 parent 7f85627 commit cc66295
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add validation to the public share provider

We added validation to the public share provider. The idea behind it is that the cs3 clients will become much simpler. The provider can do the validation and return different status codes. The API clients then just need to convert CS3 status codes to http status codes.

https://github.com/cs3org/reva/pull/4372/
https://github.com/owncloud/ocis/issues/6993
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ package publicshareprovider

import (
"context"
"fmt"
"regexp"
"strconv"
"time"

gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/v2/pkg/password"
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/v2/pkg/sharedconf"
Expand Down Expand Up @@ -260,8 +263,16 @@ func (s *service) CreatePublicShare(ctx context.Context, req *link.CreatePublicS
}

grant := req.GetGrant()
setPassword := grant.GetPassword()

expirationDateTime := cs3TimestampToTime(grant.GetExpiration()).UTC()
if expirationDateTime.Before(time.Now()) {
msg := fmt.Sprintf("expiration date is in the past: %s", expirationDateTime.Format(time.RFC3339))
return &link.CreatePublicShareResponse{
Status: status.NewFailedPrecondition(ctx, nil, msg),
}, nil
}

setPassword := grant.GetPassword()
if enforcePassword(grant, s.conf) && len(setPassword) == 0 {
return &link.CreatePublicShareResponse{
Status: status.NewFailedPrecondition(ctx, nil, "password protection is enforced"),
Expand Down Expand Up @@ -469,3 +480,7 @@ func enforcePassword(grant *link.Grant, conf *config) bool {
}
return false
}

func cs3TimestampToTime(t *typesv1beta1.Timestamp) time.Time {
return time.Unix(int64(t.Seconds), int64(t.Nanos))
}

0 comments on commit cc66295

Please sign in to comment.