Skip to content

Commit

Permalink
Remove all the quota related code (#143)
Browse files Browse the repository at this point in the history
* remove all the quota stuff

* go mod tidy
  • Loading branch information
phbnf authored Aug 19, 2024
1 parent c3d12fb commit a99b75c
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 138 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
github.com/prometheus/client_golang v1.19.1
github.com/rivo/tview v0.0.0-20240625185742-b0a7293b8130
github.com/rs/cors v1.11.0
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce
github.com/transparency-dev/formats v0.0.0-20240715203801-9ff9b9e3905f
github.com/transparency-dev/merkle v0.0.2
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,6 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce h1:fb190+cK2Xz/dvi9Hv8eCYJYvIGUTN2/KLq1pT6CjEc=
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4=
github.com/transparency-dev/formats v0.0.0-20240715203801-9ff9b9e3905f h1:NKx8BtgVYeC75VJqlsdn1DAcbmSSDQCeDw8by0m6sbA=
github.com/transparency-dev/formats v0.0.0-20240715203801-9ff9b9e3905f/go.mod h1:D/QMvgv1kz9Q1TfUcDnUcDPsiSbtLV8q8LvTCdcvygw=
github.com/transparency-dev/merkle v0.0.2 h1:Q9nBoQcZcgPamMkGn7ghV8XiTZ/kRxn1yCG81+twTK4=
Expand Down
43 changes: 0 additions & 43 deletions personalities/sctfe/cert_quota.go

This file was deleted.

57 changes: 0 additions & 57 deletions personalities/sctfe/cert_quota_test.go

This file was deleted.

19 changes: 0 additions & 19 deletions personalities/sctfe/ct_server_gcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/google/trillian/monitoring/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/cors"
"github.com/tomasen/realip"
tessera "github.com/transparency-dev/trillian-tessera"
"github.com/transparency-dev/trillian-tessera/personalities/sctfe"
"github.com/transparency-dev/trillian-tessera/personalities/sctfe/configpb"
Expand All @@ -62,13 +61,9 @@ var (
tracing = flag.Bool("tracing", false, "If true opencensus Stackdriver tracing will be enabled. See https://opencensus.io/.")
tracingProjectID = flag.String("tracing_project_id", "", "project ID to pass to stackdriver. Can be empty for GCP, consult docs for other platforms.")
tracingPercent = flag.Int("tracing_percent", 0, "Percent of requests to be traced. Zero is a special case to use the DefaultSampler")
quotaRemote = flag.Bool("quota_remote", true, "Enable requesting of quota for IP address sending incoming requests")
quotaIntermediate = flag.Bool("quota_intermediate", true, "Enable requesting of quota for intermediate certificates in submitted chains")
pkcs11ModulePath = flag.String("pkcs11_module_path", "", "Path to the PKCS#11 module to use for keys that use the PKCS#11 interface")
)

const unknownRemoteUser = "UNKNOWN_REMOTE"

// nolint:staticcheck
func main() {
klog.InitFlags(nil)
Expand Down Expand Up @@ -252,20 +247,6 @@ func setupAndRegister(ctx context.Context, deadline time.Duration, vCfg *sctfe.V
RequestLog: new(sctfe.DefaultRequestLog),
MaskInternalErrors: maskInternalErrors,
}
if *quotaRemote {
klog.Info("Enabling quota for requesting IP")
opts.RemoteQuotaUser = func(r *http.Request) string {
var remoteUser = realip.FromRequest(r)
if len(remoteUser) == 0 {
return unknownRemoteUser
}
return remoteUser
}
}
if *quotaIntermediate {
klog.Info("Enabling quota for intermediate certificates")
opts.CertificateQuotaUser = sctfe.QuotaUserForCert
}

switch vCfg.Config.StorageConfig.(type) {
case *configpb.LogConfig_Gcp:
Expand Down
17 changes: 1 addition & 16 deletions personalities/sctfe/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"net/http"
"strconv"
"strings"
"time"

"github.com/google/certificate-transparency-go/asn1"
"github.com/google/certificate-transparency-go/x509"
"github.com/google/certificate-transparency-go/x509util"
"github.com/google/trillian/crypto/keys"
"github.com/google/trillian/monitoring"
Expand All @@ -48,20 +46,7 @@ type InstanceOptions struct {
// a boolean to indicate whether the conversion succeeded.
ErrorMapper func(error) (int, bool)
// RequestLog provides structured logging of CTFE requests.
RequestLog RequestLog
// RemoteUser returns a string representing the originating host for the
// given request. This string will be used as a User quota key.
// If unset, no quota will be requested for remote users.
RemoteQuotaUser func(*http.Request) string
// CertificateQuotaUser returns a string representing the passed in
// intermediate certificate. This string will be user as a User quota key for
// the cert. Quota will be requested for each intermediate in an
// add-[pre]-chain request so as to allow individual issuers to be rate
// limited. If unset, no quota will be requested for intermediate
// certificates.
CertificateQuotaUser func(*x509.Certificate) string
// MaskInternalErrors indicates if internal server errors should be masked
// or returned to the user containing the full error message.
RequestLog RequestLog
MaskInternalErrors bool
}

Expand Down

0 comments on commit a99b75c

Please sign in to comment.