summaryrefslogtreecommitdiffstats
path: root/web/web.go
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.net>2026-01-16 17:19:27 +0000
committerLeonardo Bishop <me@leonardobishop.net>2026-01-16 17:19:27 +0000
commite6cbb8415490524034561102b6c9f03e92e4dae7 (patch)
tree2012f04c11adf636bdd06ae37f5ef3efd7a645a0 /web/web.go
parent8fc52adfdc705a1b05d3a0aef4d6e63f8ec0308d (diff)
Add OIDC auth
Diffstat (limited to 'web/web.go')
-rw-r--r--web/web.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/web/web.go b/web/web.go
index eaf03e8..dc9b5e0 100644
--- a/web/web.go
+++ b/web/web.go
@@ -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)))