diff --git a/go.mod b/go.mod index 3b49637..c47c09e 100644 --- a/go.mod +++ b/go.mod @@ -11,13 +11,13 @@ require ( github.com/aaronland/go-http-server v1.5.0 github.com/rs/cors v1.11.1 github.com/sfomuseum/go-flags v0.10.0 - github.com/sfomuseum/go-http-auth v0.11.0 + github.com/sfomuseum/go-http-auth v0.12.0 github.com/sfomuseum/go-timings v1.4.0 github.com/whosonfirst/go-reader v1.0.2 github.com/whosonfirst/go-reader-cachereader v1.1.1 github.com/whosonfirst/go-whosonfirst-iterate/v2 v2.5.0 github.com/whosonfirst/go-whosonfirst-placetypes v0.7.3 - github.com/whosonfirst/go-whosonfirst-spatial v0.11.0 + github.com/whosonfirst/go-whosonfirst-spatial v0.11.1 github.com/whosonfirst/go-whosonfirst-spr-geojson v0.0.8 github.com/whosonfirst/go-whosonfirst-uri v1.3.0 ) diff --git a/go.sum b/go.sum index de3017a..fe1c97f 100644 --- a/go.sum +++ b/go.sum @@ -235,8 +235,8 @@ github.com/sfomuseum/go-edtf v1.2.1 h1:vyKvoNa4p6mmwp9AbbEdJoj+A5YK4G7S1QgmSNpXh github.com/sfomuseum/go-edtf v1.2.1/go.mod h1:1rP0EJZ/84j3HO80vGcnG2T9MFBDAFyTNtjrr8cv3T4= github.com/sfomuseum/go-flags v0.10.0 h1:1OC1ACxpWMsl3XQ9OeNVMQj7Zi2CzufP3Rym3mPI8HU= github.com/sfomuseum/go-flags v0.10.0/go.mod h1:VXOnnX1/yxQpX2yiwHaBV6aCmhtszQOL5bL1/nNo3co= -github.com/sfomuseum/go-http-auth v0.11.0 h1:4p4SynsSVR+s5tc4L3SAQ5nCaf5VD/331sxR9EFmgyE= -github.com/sfomuseum/go-http-auth v0.11.0/go.mod h1:m0I60r/aVlWXia43eoZOp/d0u7M7pURgJEYElvVVe98= +github.com/sfomuseum/go-http-auth v0.12.0 h1:eoWEpjwcZ6IsCtCXaOxUVtVpLIKR5lG9dlHjGHcyDak= +github.com/sfomuseum/go-http-auth v0.12.0/go.mod h1:m0I60r/aVlWXia43eoZOp/d0u7M7pURgJEYElvVVe98= github.com/sfomuseum/go-http-protomaps v0.3.0 h1:e89s6wsDHyCXDgB6hFARMjsdrgn/lG4BRybRJuXTktY= github.com/sfomuseum/go-http-protomaps v0.3.0/go.mod h1:K/PDDhy0c3xcPK2Bot7+oIz2l8QQLZys9SqAblhHT6I= github.com/sfomuseum/go-http-rollup v0.0.3 h1:N3CnjZluhzRhqPpdM+GTuzCnjM0V5xtPX+LeCgZWhTA= @@ -303,8 +303,8 @@ github.com/whosonfirst/go-whosonfirst-placetypes v0.7.3 h1:BuKRV3pal5wanOZxWue7h github.com/whosonfirst/go-whosonfirst-placetypes v0.7.3/go.mod h1:lRvLpHHUPxfrU3c4xCcdmFbU1dYJLpO2WQ1LJWoqYJ8= github.com/whosonfirst/go-whosonfirst-sources v0.1.0 h1:JuKLa6KWke22jBfJ1pM9WQHoz1/3pbDv2C+aR+THPPQ= github.com/whosonfirst/go-whosonfirst-sources v0.1.0/go.mod h1:EUMHyGzUmqPPxlMmOp+28BFeoBdxxE0HCKRd67lkqGM= -github.com/whosonfirst/go-whosonfirst-spatial v0.11.0 h1:+ptVNprdT9PuwJmsA4tnrxLmiOnYUHjKzbmXmhUdzKA= -github.com/whosonfirst/go-whosonfirst-spatial v0.11.0/go.mod h1:ja79l9imEriYcWFVX1vbW4eMAf407/GqEQ3q5Fpa/1A= +github.com/whosonfirst/go-whosonfirst-spatial v0.11.1 h1:EUYDE5I6ojL+70VL+B3unmCE3ehb0E/cHkf+mql45QE= +github.com/whosonfirst/go-whosonfirst-spatial v0.11.1/go.mod h1:ja79l9imEriYcWFVX1vbW4eMAf407/GqEQ3q5Fpa/1A= github.com/whosonfirst/go-whosonfirst-spr-geojson v0.0.8 h1:K0rCaKo0xvOtuS/x9r62bEfIK3OTdZqbDmgG+A3xDSs= github.com/whosonfirst/go-whosonfirst-spr-geojson v0.0.8/go.mod h1:Nh7PwBMDT1kUrp9jBMFw+Ilue6up1tz2KhE39btS/ZU= github.com/whosonfirst/go-whosonfirst-spr/v2 v2.3.7 h1:1j4IMuVua4/NhqKm2ke16h2V5Z2XiLoOdXbjDrfZb0E= diff --git a/http/api/pip.go b/http/api/pip.go index ab55205..acece87 100644 --- a/http/api/pip.go +++ b/http/api/pip.go @@ -2,7 +2,7 @@ package api import ( "encoding/json" - "log" + "log/slog" "net/http" "github.com/aaronland/go-http-sanitize" @@ -25,7 +25,6 @@ const GEOJSON string = "application/geo+json" type PointInPolygonHandlerOptions struct { EnableGeoJSON bool - Logger *log.Logger LogTimings bool } @@ -54,7 +53,7 @@ func PointInPolygonHandler(app *spatial_app.SpatialApplication, opts *PointInPol if opts.LogTimings { for _, t := range app.Timings { - opts.Logger.Println(t) + slog.Debug("Timings", "timing", t) } } }() diff --git a/vendor/github.com/sfomuseum/go-http-auth/README.md b/vendor/github.com/sfomuseum/go-http-auth/README.md index 7e18931..4d8589c 100644 --- a/vendor/github.com/sfomuseum/go-http-auth/README.md +++ b/vendor/github.com/sfomuseum/go-http-auth/README.md @@ -8,7 +8,7 @@ Go package to provide a simple interface for enforcing authentication in HTTP ha ## Important -This work is nearly settled (at least for a "v1" release) but may still change. +This work is nearly settled (at least for a "v1" release) but may still change. For example the `SetLogger` method will probably be removed and individual handlers will simply call `log/slog` methods assuming that the "default" logger and log level have been assigned separately in application code. ## Motivation @@ -21,7 +21,7 @@ type Authenticator interface { // WrapHandler wraps a `http.Handler` with any implementation-specific middleware. WrapHandler(http.Handler) http.Handler // GetAccountForRequest returns an `Account` instance for an HTTP request. - GetAccountForRequest(*http.Request) (*Account, error) + GetAccountForRequest(*http.Request) (Account, error) // SigninHandler returns a `http.Handler` for implementing account signin. SigninHandler() http.Handler // SignoutHandler returns a `http.Handler` for implementing account signout. @@ -33,19 +33,19 @@ type Authenticator interface { } ``` -All the web application (specifically its `net/http.Handler` instances) know is that it has an implementation of the `auth.Authenticator` interface which exposes a `GetAccountForRequest` method which returns an `auth.Account` struct or an error. +All the web application (specifically its `net/http.Handler` instances) know is that it has an implementation of the `auth.Authenticator` interface which exposes a `GetAccountForRequest` method which returns an implementation of the `auth.Account` interface or an error. ``` -// type Account is a struct that defines minimal information for an account. -type Account struct { - // The unique ID associated with this account. - Id int64 `json:"id"` +// type Account is an interface that defines minimal information for an account. +type Account interface { + // The unique ID associated with this account. + Id() int64 // The name associated with this account. - Name string `json:"name"` + Name() string } ``` -Account structs are _not_ meant to be accurate reflections of the underlying implementation's account structure but rather a minimalist struct containing on an account name and unique identifier. +Account interfaces/implementations meant to be accurate reflections of the underlying implementation's account structure but rather a minimalist struct containing on an account name and unique identifier. Here is a simplified example, with error handling omitted for brevity, that uses the built-in `null://` Authenticator implementation (that will always return a `Account` instance with ID "0"): @@ -83,7 +83,7 @@ func Handler(opts *HandlerOptions) (http.Handler, error) { } } - log.Printf("Authenticated as %s (%d)\n", acct.Name, acct.Id) + log.Printf("Authenticated as %s (%d)\n", acct.Name(), acct.Id()) ... carry on with handler } diff --git a/vendor/github.com/sfomuseum/go-http-auth/account.go b/vendor/github.com/sfomuseum/go-http-auth/account.go index 3d26760..d5f54ea 100644 --- a/vendor/github.com/sfomuseum/go-http-auth/account.go +++ b/vendor/github.com/sfomuseum/go-http-auth/account.go @@ -1,9 +1,37 @@ package auth -// type Account is a struct that defines minimal information for an account. -type Account struct { +// type Account is an interface that defines minimal information for an account. +type Account interface { // The unique ID associated with this account. - Id int64 `json:"id"` + Id() int64 // The name associated with this account. - Name string `json:"name"` + Name() string +} + +// NewAccount returns a new instance of `BasicAccount` (which implements the `Account` interface) for 'id' and 'name'. +func NewAccount(id int64, name string) Account { + + return &BasicAccount{ + AccountId: id, + AccountName: name, + } +} + +// BasicAccount is the simplest (most basic) implementation of the `Account` interface for wrapping a unique account ID and an account name. +type BasicAccount struct { + Account `json:",omitempty"` + // The unique ID associated with this account. + AccountId int64 `json:"id"` + // The name associated with this account. + AccountName string `json:"name"` +} + +// Returns the unique ID associated with 'a'. +func (a *BasicAccount) Id() int64 { + return a.AccountId +} + +// Returns the name associated with 'a'. +func (a *BasicAccount) Name() string { + return a.AccountName } diff --git a/vendor/github.com/sfomuseum/go-http-auth/auth.go b/vendor/github.com/sfomuseum/go-http-auth/auth.go index b5a7afa..2e207e6 100644 --- a/vendor/github.com/sfomuseum/go-http-auth/auth.go +++ b/vendor/github.com/sfomuseum/go-http-auth/auth.go @@ -17,7 +17,7 @@ type Authenticator interface { // WrapHandler wraps a `http.Handler` with any implementation-specific middleware. WrapHandler(http.Handler) http.Handler // GetAccountForRequest returns an `Account` instance for an HTTP request. - GetAccountForRequest(*http.Request) (*Account, error) + GetAccountForRequest(*http.Request) (Account, error) // SigninHandler returns a `http.Handler` for implementing account signin. SigninHandler() http.Handler // SignoutHandler returns a `http.Handler` for implementing account signout. diff --git a/vendor/github.com/sfomuseum/go-http-auth/none.go b/vendor/github.com/sfomuseum/go-http-auth/none.go index e31746b..3a990be 100644 --- a/vendor/github.com/sfomuseum/go-http-auth/none.go +++ b/vendor/github.com/sfomuseum/go-http-auth/none.go @@ -31,8 +31,7 @@ func (a *NoneAuthenticator) WrapHandler(h http.Handler) http.Handler { } // GetAccountForRequest returns an stub `Account` instance. -func (a *NoneAuthenticator) GetAccountForRequest(req *http.Request) (*Account, error) { - +func (a *NoneAuthenticator) GetAccountForRequest(req *http.Request) (Account, error) { return nil, NotAuthorized{} } diff --git a/vendor/github.com/sfomuseum/go-http-auth/null.go b/vendor/github.com/sfomuseum/go-http-auth/null.go index 9596ad4..cf0354c 100644 --- a/vendor/github.com/sfomuseum/go-http-auth/null.go +++ b/vendor/github.com/sfomuseum/go-http-auth/null.go @@ -31,13 +31,9 @@ func (a *NullAuthenticator) WrapHandler(h http.Handler) http.Handler { } // GetAccountForRequest returns an stub `Account` instance. -func (a *NullAuthenticator) GetAccountForRequest(req *http.Request) (*Account, error) { - - acct := &Account{ - Id: 0, - Name: "Null", - } +func (a *NullAuthenticator) GetAccountForRequest(req *http.Request) (Account, error) { + acct := NewAccount(0, "Null") return acct, nil } diff --git a/vendor/github.com/sfomuseum/go-http-auth/shared_secret.go b/vendor/github.com/sfomuseum/go-http-auth/shared_secret.go index 5946539..37390de 100644 --- a/vendor/github.com/sfomuseum/go-http-auth/shared_secret.go +++ b/vendor/github.com/sfomuseum/go-http-auth/shared_secret.go @@ -83,7 +83,7 @@ func (a *SharedSecretAuthenticator) WrapHandler(next http.Handler) http.Handler } // GetAccountForRequest returns an stub `Account` instance for requests that contain a valid `X-Shared-Secret` HTTP header. -func (a *SharedSecretAuthenticator) GetAccountForRequest(req *http.Request) (*Account, error) { +func (a *SharedSecretAuthenticator) GetAccountForRequest(req *http.Request) (Account, error) { secret := req.Header.Get(SHARED_SECRET_HEADER) @@ -91,11 +91,7 @@ func (a *SharedSecretAuthenticator) GetAccountForRequest(req *http.Request) (*Ac return nil, NotAuthorized{} } - acct := &Account{ - Id: SHARED_SECRET_ACCOUNT_ID, - Name: SHARED_SECRET_ACCOUNT_NAME, - } - + acct := NewAccount(SHARED_SECRET_ACCOUNT_ID, SHARED_SECRET_ACCOUNT_NAME) return acct, nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 1b20b88..a73ab75 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -358,7 +358,7 @@ github.com/sfomuseum/go-edtf/tests ## explicit; go 1.16 github.com/sfomuseum/go-flags/flagset github.com/sfomuseum/go-flags/multi -# github.com/sfomuseum/go-http-auth v0.11.0 +# github.com/sfomuseum/go-http-auth v0.12.0 ## explicit; go 1.18 github.com/sfomuseum/go-http-auth # github.com/sfomuseum/go-http-protomaps v0.3.0 @@ -457,7 +457,7 @@ github.com/whosonfirst/go-whosonfirst-placetypes ## explicit; go 1.12 github.com/whosonfirst/go-whosonfirst-sources github.com/whosonfirst/go-whosonfirst-sources/sources -# github.com/whosonfirst/go-whosonfirst-spatial v0.11.0 +# github.com/whosonfirst/go-whosonfirst-spatial v0.11.1 ## explicit; go 1.23 github.com/whosonfirst/go-whosonfirst-spatial github.com/whosonfirst/go-whosonfirst-spatial/application