Skip to content

Commit

Permalink
bearer: Deny some content-type uploads
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Sep 20, 2023
1 parent edd6738 commit 008a35f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bearer/bearer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
"github.com/nspcc-dev/neofs-sdk-go/eacl"
"github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/user"
)

Expand Down Expand Up @@ -40,6 +41,12 @@ func (b *Generator) NewBearer(email string, currentEpoch uint64) (string, string
// order of rec is important
rec := eacl.CreateRecord(eacl.ActionAllow, eacl.OperationPut)
rec.AddObjectAttributeFilter(eacl.MatchStringEqual, b.config.EmailAttr, hashedEmail)
rec.AddFilter(eacl.HeaderFromObject, eacl.MatchStringNotEqual, object.AttributeContentType, "application/javascript")
rec.AddFilter(eacl.HeaderFromObject, eacl.MatchStringNotEqual, object.AttributeContentType, "text/javascript")
rec.AddFilter(eacl.HeaderFromObject, eacl.MatchStringNotEqual, object.AttributeContentType, "application/xhtml+xml")
rec.AddFilter(eacl.HeaderFromObject, eacl.MatchStringNotEqual, object.AttributeContentType, "text/html")
rec.AddFilter(eacl.HeaderFromObject, eacl.MatchStringNotEqual, object.AttributeContentType, "text/htmlh")
rec.AddFilter(eacl.HeaderFromObject, eacl.MatchStringNotEqual, object.AttributeContentType, "")
eacl.AddFormedTarget(rec, eacl.RoleOthers)
t.AddRecord(rec)
rec2 := eacl.CreateRecord(eacl.ActionDeny, eacl.OperationPut)
Expand Down

0 comments on commit 008a35f

Please sign in to comment.