diff options
| author | Leonardo Bishop <me@leonardobishop.net> | 2026-01-16 17:19:27 +0000 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.net> | 2026-01-16 17:19:27 +0000 |
| commit | e6cbb8415490524034561102b6c9f03e92e4dae7 (patch) | |
| tree | 2012f04c11adf636bdd06ae37f5ef3efd7a645a0 /web/web.go | |
| parent | 8fc52adfdc705a1b05d3a0aef4d6e63f8ec0308d (diff) | |
Add OIDC auth
Diffstat (limited to 'web/web.go')
| -rw-r--r-- | web/web.go | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -5,6 +5,7 @@ import ( "html/template" "net/http" + "git.leonardobishop.net/instancer/pkg/auth" "git.leonardobishop.net/instancer/pkg/deployer" "git.leonardobishop.net/instancer/pkg/registry" "git.leonardobishop.net/instancer/pkg/session" @@ -15,7 +16,7 @@ import ( //go:embed views var views embed.FS -func NewMux(registryClient *registry.RegistryClient, dockerDeployer *deployer.DockerDeployer) *http.ServeMux { +func NewMux(registryClient *registry.RegistryClient, dockerDeployer *deployer.DockerDeployer, oidcAuthProvider *auth.OIDCAuthProvider) *http.ServeMux { tmpl, err := template.ParseFS(views, "views/*.html") if err != nil { panic(err) @@ -23,10 +24,11 @@ func NewMux(registryClient *registry.RegistryClient, dockerDeployer *deployer.Do mux := http.NewServeMux() store := session.NewMemoryStore() - mustAuthenticate := middleware.MustAuthenticate(store) + mustAuthenticate := middleware.MustAuthenticate(tmpl, store, oidcAuthProvider) - mux.HandleFunc("GET /auth", handler.GetAuth(tmpl)) - mux.HandleFunc("POST /auth", handler.PostAuth(tmpl, store)) + mux.HandleFunc("GET /auth", handler.GetAuth(tmpl, oidcAuthProvider)) + mux.HandleFunc("POST /auth", handler.PostAuth(tmpl, store, oidcAuthProvider)) + mux.HandleFunc("GET /auth/callback", handler.GetAuthCallback(tmpl, store, oidcAuthProvider)) mux.HandleFunc("GET /logout", handler.GetLogout(store)) mux.HandleFunc("GET /", mustAuthenticate(handler.GetIndex(tmpl, registryClient))) |
