diff --git a/cmd/server/container.go b/cmd/server/container.go index 62107c8..3d89d34 100644 --- a/cmd/server/container.go +++ b/cmd/server/container.go @@ -67,6 +67,9 @@ func getServiceContainer(ctx context.Context, conf *config.Config) (*service.Con conf.HTTP.TemplateDir, )) + // Create and expose config service provider + ctn.Provide(config.ServiceName, config.ServiceProvider(conf)) + defaultHTTPTransport, ok := http.DefaultTransport.(*http.Transport) if ok { if defaultHTTPTransport.TLSClientConfig == nil { @@ -81,9 +84,6 @@ func getServiceContainer(ctx context.Context, conf *config.Config) (*service.Con ) } - // Create and expose config service provider - ctn.Provide(config.ServiceName, config.ServiceProvider(conf)) - provider, err := oidc.NewProvider(ctx, conf.OIDC.IssuerURL) if err != nil { return nil, errors.Wrap(err, "could not create oidc provider") diff --git a/cmd/server/main.go b/cmd/server/main.go index 76f89b3..ef9917c 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -2,21 +2,19 @@ package main import ( "context" + "flag" + "fmt" + "log" "net/http" + "os" "forge.cadoles.com/wpetit/goweb-oidc/internal/config" "forge.cadoles.com/wpetit/goweb-oidc/internal/route" - "github.com/go-chi/chi" - "github.com/go-chi/chi/middleware" + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" "gitlab.com/wpetit/goweb/middleware/container" - "flag" - "fmt" - "log" - - "os" - "github.com/pkg/errors" "gitlab.com/wpetit/goweb/logger" ) @@ -89,7 +87,6 @@ func main() { } else { conf = config.NewDefault() } - } // Dump configuration if asked @@ -140,6 +137,7 @@ func main() { r := chi.NewRouter() // Define base middlewares + r.Use(middleware.CleanPath) r.Use(middleware.Logger) r.Use(middleware.Recoverer) diff --git a/cmd/server/template/blocks/header.html.tmpl b/cmd/server/template/blocks/header.html.tmpl index b7eaeee..b2ae7b0 100644 --- a/cmd/server/template/blocks/header.html.tmpl +++ b/cmd/server/template/blocks/header.html.tmpl @@ -3,7 +3,7 @@
diff --git a/cmd/server/template/layouts/home.html.tmpl b/cmd/server/template/layouts/home.html.tmpl index 0c623e4..3280993 100644 --- a/cmd/server/template/layouts/home.html.tmpl +++ b/cmd/server/template/layouts/home.html.tmpl @@ -1,4 +1,4 @@ -{{define "title"}}Home | OIDC Test App{{end}} +{{define "title"}}Home | OIDC Tester{{end}} {{define "body"}}
diff --git a/cmd/server/template/layouts/profile.html.tmpl b/cmd/server/template/layouts/profile.html.tmpl index 0c9c965..530abea 100644 --- a/cmd/server/template/layouts/profile.html.tmpl +++ b/cmd/server/template/layouts/profile.html.tmpl @@ -1,4 +1,4 @@ -{{define "title"}}Profile | OIDC Test App{{end}} +{{define "title"}}Profile | OIDC Tester{{end}} {{define "body"}}
diff --git a/go.mod b/go.mod index ad2e3d7..857bcff 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,8 @@ require ( github.com/caarlos0/env/v6 v6.2.2 github.com/coreos/go-oidc v2.2.1+incompatible github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5 - github.com/go-chi/chi v4.1.0+incompatible + github.com/go-chi/chi v4.1.2+incompatible // indirect + github.com/go-chi/chi/v5 v5.0.7 github.com/google/go-cmp v0.4.0 // indirect github.com/gorilla/sessions v1.2.0 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index bdb55e3..ef14dac 100644 --- a/go.sum +++ b/go.sum @@ -52,8 +52,10 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= -github.com/go-chi/chi v4.1.0+incompatible h1:ETj3cggsVIY2Xao5ExCu6YhEh5MD6JTfcBzS37R260w= -github.com/go-chi/chi v4.1.0+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= +github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8= +github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= diff --git a/internal/route/mount.go b/internal/route/mount.go index 4b073f2..f3b8827 100644 --- a/internal/route/mount.go +++ b/internal/route/mount.go @@ -4,12 +4,11 @@ import ( oidc "forge.cadoles.com/wpetit/goweb-oidc" "forge.cadoles.com/wpetit/goweb-oidc/internal/config" - "github.com/go-chi/chi" + chi "github.com/go-chi/chi/v5" "gitlab.com/wpetit/goweb/static" ) func Mount(r *chi.Mux, config *config.Config) error { - r.With(oidc.HandleCallback).Get("/oauth2/callback", handleLoginCallback) r.Get("/", serveHomePage) r.Get("/logout", handleLogout)