Skip to content

Commit

Permalink
satellite/metainfo: return permission denied when limits are 0
Browse files Browse the repository at this point in the history
Change-Id: I1e87124d33526dca30ca6b972c4126584017de8b
  • Loading branch information
Jacob Willoughby authored and jtolio committed Apr 2, 2024
1 parent 6943fec commit e4191b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions satellite/console/accountfreezes_test.go
Expand Up @@ -579,12 +579,12 @@ func TestFreezeEffects(t *testing.T) {
// Should not be able to list.
_, err := uplink1.ListObjects(ctx, sat, bucketName)
require.Error(testT, err)
require.ErrorIs(testT, err, uplink.ErrTooManyRequests)
require.ErrorIs(testT, err, uplink.ErrPermissionDenied)

// Should not be able to delete.
err = uplink1.DeleteObject(ctx, sat, bucketName, path)
require.Error(testT, err)
require.ErrorIs(testT, err, uplink.ErrTooManyRequests)
require.ErrorIs(testT, err, uplink.ErrPermissionDenied)
}

t.Run("BillingFreeze effect on project owner", func(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions satellite/metainfo/validation.go
Expand Up @@ -230,6 +230,9 @@ func (endpoint *Endpoint) checkRate(ctx context.Context, apiKeyInfo *console.API
}

if !limiter.Allow() {
if limiter.Burst() == 0 && limiter.Limit() == 0 {
return rpcstatus.Error(rpcstatus.PermissionDenied, "All access disabled")
}
endpoint.log.Warn("too many requests for project",
zap.Stringer("Project ID", apiKeyInfo.ProjectID),
zap.Float64("rate limit", float64(limiter.Limit())),
Expand Down

0 comments on commit e4191b6

Please sign in to comment.