Skip to content

Commit

Permalink
feat: add GET _/info
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Jan 2, 2023
1 parent 5b3ef2d commit d86914f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
5 changes: 4 additions & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/formancehq/auth/pkg/delegatedauth"
"github.com/formancehq/auth/pkg/oidc"
"github.com/formancehq/auth/pkg/storage/sqlstorage"
"github.com/formancehq/go-libs/sharedapi"
"github.com/formancehq/go-libs/sharedlogging"
"github.com/formancehq/go-libs/sharedotlp/pkg/sharedotlptraces"
"github.com/pkg/errors"
Expand Down Expand Up @@ -142,7 +143,9 @@ var serveCmd = &cobra.Command{
ClientSecret: delegatedClientSecret,
RedirectURL: fmt.Sprintf("%s/authorize/callback", viper.GetString(baseUrlFlag)),
}),
api.Module(viper.GetString(listenFlag)),
api.Module(viper.GetString(listenFlag), sharedapi.ServiceInfo{
Version: Version,
}),
oidc.Module(key, viper.GetString(baseUrlFlag), o.Clients...),
authorization.Module(),
sqlstorage.Module(sqlstorage.KindPostgres, viper.GetString(postgresUriFlag),
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module github.com/formancehq/auth
go 1.18

require (
github.com/formancehq/go-libs v1.2.1-0.20221124082706-09db8cefd5b4
github.com/formancehq/go-libs v1.3.0
github.com/formancehq/go-libs/sharedapi v0.0.0-20221216091331-d43b8d37bc84
github.com/formancehq/go-libs/sharedhealth v0.0.0-20221124082706-09db8cefd5b4
github.com/formancehq/go-libs/sharedotlp v0.0.0-20221124082706-09db8cefd5b4
github.com/golang-jwt/jwt v3.2.2+incompatible
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
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/formancehq/go-libs v1.2.1-0.20221124082706-09db8cefd5b4 h1:dyyLZWtcnyZvygR7/4VIdha+s8Qb7ZCuxgAj/FVzdKo=
github.com/formancehq/go-libs v1.2.1-0.20221124082706-09db8cefd5b4/go.mod h1:9pIcaXQR4O1biXDfhFurYJZw1piU6sJk+0Vqvu+92ng=
github.com/formancehq/go-libs v1.3.0 h1:Ogs/B9FcoGHl2yF0TeTrBoGejKQk0G7XH6pFwgCod3U=
github.com/formancehq/go-libs v1.3.0/go.mod h1:9pIcaXQR4O1biXDfhFurYJZw1piU6sJk+0Vqvu+92ng=
github.com/formancehq/go-libs/sharedapi v0.0.0-20221216091331-d43b8d37bc84 h1:9mgfYd6l5bHj7xhbbLKLupKknjQvVlF+r7fMacxoqDM=
github.com/formancehq/go-libs/sharedapi v0.0.0-20221216091331-d43b8d37bc84/go.mod h1:PMf25p7rXNJkc/LIwvf0AmGfAo1NqwQG+5emONMrurA=
github.com/formancehq/go-libs/sharedhealth v0.0.0-20221124082706-09db8cefd5b4 h1:Q6sfMjue0xoqRKU/s4TqC0pUid1rh5/bbDV5GbmJ7/U=
github.com/formancehq/go-libs/sharedhealth v0.0.0-20221124082706-09db8cefd5b4/go.mod h1:4TBSSGGBeY6xCaqI4gw74ouwgirdZjvKlv001kQ8xp0=
github.com/formancehq/go-libs/sharedotlp v0.0.0-20221124082706-09db8cefd5b4 h1:cUfocGRkHYKOXkVZwhmbC0Q70aVo/ezhSSNbo2IVZ58=
Expand Down
9 changes: 8 additions & 1 deletion pkg/api/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"net/http"

"github.com/formancehq/go-libs/sharedapi"
sharedhealth "github.com/formancehq/go-libs/sharedhealth/pkg"
"github.com/gorilla/mux"
"go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux"
Expand All @@ -22,10 +23,15 @@ func CreateRootRouter() *mux.Router {
return rootRouter
}

func Module(addr string) fx.Option {
func addInfoRoute(router *mux.Router, serviceInfo sharedapi.ServiceInfo) {
router.Path("/_info").Methods(http.MethodGet).HandlerFunc(sharedapi.InfoHandler(serviceInfo))
}

func Module(addr string, serviceInfo sharedapi.ServiceInfo) fx.Option {
return fx.Options(
sharedhealth.ProvideHealthCheck(delegatedOIDCServerAvailability),
sharedhealth.Module(),
fx.Supply(serviceInfo),
fx.Provide(CreateRootRouter),
fx.Invoke(func(lc fx.Lifecycle, r *mux.Router, healthController *sharedhealth.HealthController) {
finalRouter := mux.NewRouter()
Expand All @@ -38,6 +44,7 @@ func Module(addr string) fx.Option {
})
}),
fx.Invoke(
addInfoRoute,
addClientRoutes,
addScopeRoutes,
addUserRoutes,
Expand Down

0 comments on commit d86914f

Please sign in to comment.