diff --git a/cmd/serve_cmd.go b/cmd/serve_cmd.go index 52b4ad375..8423509ae 100644 --- a/cmd/serve_cmd.go +++ b/cmd/serve_cmd.go @@ -32,7 +32,7 @@ func serve(ctx context.Context) { } defer db.Close() - api := api.NewAPIWithVersion(ctx, config, db, utilities.Version) + api := api.NewAPIWithVersion(config, db, utilities.Version) addr := net.JoinHostPort(config.API.Host, config.API.Port) logrus.Infof("GoTrue API started on: %s", addr) diff --git a/go.mod b/go.mod index 57ddf929d..2feeaebfb 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc github.com/coreos/go-oidc/v3 v3.6.0 github.com/didip/tollbooth/v5 v5.1.1 - github.com/go-chi/chi v4.0.2+incompatible github.com/gobuffalo/validate/v3 v3.3.3 // indirect github.com/gobwas/glob v0.2.3 github.com/gofrs/uuid v4.3.1+incompatible @@ -68,6 +67,7 @@ require ( github.com/crewjam/saml v0.4.14 github.com/deepmap/oapi-codegen v1.12.4 github.com/fatih/structs v1.1.0 + github.com/go-chi/chi/v5 v5.0.12 github.com/gobuffalo/pop/v6 v6.1.1 github.com/jackc/pgx/v4 v4.18.2 github.com/standard-webhooks/standard-webhooks/libraries v0.0.0-20240303152453-e0e82adf1721 diff --git a/go.sum b/go.sum index ce6cb9af3..2e5cb69e0 100644 --- a/go.sum +++ b/go.sum @@ -127,8 +127,8 @@ github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs= -github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= +github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -490,8 +490,6 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/supabase/hibp v0.0.0-20231124125943-d225752ae869 h1:VDuRtwen5Z7QQ5ctuHUse4wAv/JozkKZkdic5vUV4Lg= github.com/supabase/hibp v0.0.0-20231124125943-d225752ae869/go.mod h1:eHX5nlSMSnyPjUrbYzeqrA8snCe2SKyfizKjU3dkfOw= -github.com/supabase/mailme v0.1.0 h1:1InJqMMPTFqZfRZ/gnsCwOc+oUWCFuxSXhlCCG6zYUo= -github.com/supabase/mailme v0.1.0/go.mod h1:kWsnmPfUBZTavlXYkfJrE9unzmmRAIi/kqsxXfEWEY8= github.com/supabase/mailme v0.2.0 h1:39LHZ4+YOeqoN4MiuncPBC3JarExAa0flmokM24qHNU= github.com/supabase/mailme v0.2.0/go.mod h1:kWsnmPfUBZTavlXYkfJrE9unzmmRAIi/kqsxXfEWEY8= github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg= diff --git a/internal/api/admin.go b/internal/api/admin.go index df837c305..dfb5bf8fa 100644 --- a/internal/api/admin.go +++ b/internal/api/admin.go @@ -8,7 +8,7 @@ import ( "time" "github.com/fatih/structs" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "github.com/gofrs/uuid" "github.com/sethvargo/go-password/password" "github.com/supabase/auth/internal/api/provider" diff --git a/internal/api/api.go b/internal/api/api.go index 26207861f..51d443331 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -1,14 +1,12 @@ package api import ( - "context" "net/http" "regexp" "time" "github.com/didip/tollbooth/v5" "github.com/didip/tollbooth/v5/limiter" - "github.com/go-chi/chi" "github.com/rs/cors" "github.com/sebest/xff" "github.com/sirupsen/logrus" @@ -51,7 +49,7 @@ func (a *API) Now() time.Time { // NewAPI instantiates a new REST API func NewAPI(globalConfig *conf.GlobalConfiguration, db *storage.Connection) *API { - return NewAPIWithVersion(context.Background(), globalConfig, db, defaultVersion) + return NewAPIWithVersion(globalConfig, db, defaultVersion) } func (a *API) deprecationNotices() { @@ -69,7 +67,7 @@ func (a *API) deprecationNotices() { } // NewAPIWithVersion creates a new REST API using the specified version -func NewAPIWithVersion(ctx context.Context, globalConfig *conf.GlobalConfiguration, db *storage.Connection, version string) *API { +func NewAPIWithVersion(globalConfig *conf.GlobalConfiguration, db *storage.Connection, version string) *API { api := &API{config: globalConfig, db: db, version: version} if api.config.Password.HIBP.Enabled { @@ -293,7 +291,7 @@ func NewAPIWithVersion(ctx context.Context, globalConfig *conf.GlobalConfigurati AllowCredentials: true, }) - api.handler = corsHandler.Handler(chi.ServerBaseContext(ctx, r)) + api.handler = corsHandler.Handler(r) return api } diff --git a/internal/api/api_test.go b/internal/api/api_test.go index 032e98a43..87639a09c 100644 --- a/internal/api/api_test.go +++ b/internal/api/api_test.go @@ -1,7 +1,6 @@ package api import ( - "context" "testing" "github.com/stretchr/testify/require" @@ -46,7 +45,7 @@ func setupAPIForTestWithCallback(cb func(*conf.GlobalConfiguration, *storage.Con cb(nil, conn) } - return NewAPIWithVersion(context.Background(), config, conn, apiTestVersion), config, nil + return NewAPIWithVersion(config, conn, apiTestVersion), config, nil } func TestEmailEnabledByDefault(t *testing.T) { diff --git a/internal/api/identity.go b/internal/api/identity.go index e3bcf3cad..7acf7c25c 100644 --- a/internal/api/identity.go +++ b/internal/api/identity.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/fatih/structs" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "github.com/gofrs/uuid" "github.com/pkg/errors" "github.com/supabase/auth/internal/api/provider" diff --git a/internal/api/router.go b/internal/api/router.go index 70b41f22d..1feb66d3f 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" ) func newRouter() *router { diff --git a/internal/api/ssoadmin.go b/internal/api/ssoadmin.go index fae328c4f..72d88dbac 100644 --- a/internal/api/ssoadmin.go +++ b/internal/api/ssoadmin.go @@ -10,7 +10,7 @@ import ( "github.com/crewjam/saml" "github.com/crewjam/saml/samlsp" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "github.com/gofrs/uuid" "github.com/supabase/auth/internal/models" "github.com/supabase/auth/internal/observability" diff --git a/internal/observability/request-logger.go b/internal/observability/request-logger.go index 3e7a7e356..804feca3b 100644 --- a/internal/observability/request-logger.go +++ b/internal/observability/request-logger.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - chimiddleware "github.com/go-chi/chi/middleware" + chimiddleware "github.com/go-chi/chi/v5/middleware" "github.com/gofrs/uuid" "github.com/sirupsen/logrus" "github.com/supabase/auth/internal/conf" @@ -68,7 +68,7 @@ type logEntry struct { Entry *logrus.Entry } -func (e *logEntry) Write(status, bytes int, elapsed time.Duration) { +func (e *logEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{}) { entry := e.Entry.WithFields(logrus.Fields{ "status": status, "duration": elapsed.Nanoseconds(), diff --git a/internal/observability/request-tracing.go b/internal/observability/request-tracing.go index c35925547..aefa994db 100644 --- a/internal/observability/request-tracing.go +++ b/internal/observability/request-tracing.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "github.com/sirupsen/logrus" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "go.opentelemetry.io/otel/attribute"