aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/router.go
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-12-11 17:05:12 +0100
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-12-11 17:05:12 +0100
commit1e45ae2ea3497958b2ea6a20137955cfc3bbc964 (patch)
tree00af0e28864d79d7a9cbb8b693aff1b397b1a949 /pkg/handler/router.go
parente6ded0d01117c592ec124f3e02d6c89eeafec382 (diff)
downloadcerrado-1e45ae2ea3497958b2ea6a20137955cfc3bbc964.tar.gz
cerrado-1e45ae2ea3497958b2ea6a20137955cfc3bbc964.tar.bz2
cerrado-1e45ae2ea3497958b2ea6a20137955cfc3bbc964.zip
feat: Add UI/Handler login process
It adds the whole workflow to store and handle login on both UI and handler level. With that the login information should be available at any point given the context.
Diffstat (limited to 'pkg/handler/router.go')
-rw-r--r--pkg/handler/router.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/handler/router.go b/pkg/handler/router.go
index 32bd78a..ee4081b 100644
--- a/pkg/handler/router.go
+++ b/pkg/handler/router.go
@@ -17,12 +17,13 @@ import (
// its sub package don't leak in other places.
func MountHandler(
gitService *service.GitService,
+ authService *service.AuthService,
configRepo *serverconfig.ConfigurationRepository,
) (http.Handler, error) {
var (
gitHandler = git.NewGitHandler(gitService, configRepo)
aboutHandler = about.NewAboutHandler(configRepo)
- loginHandler = &auth.LoginHandler{}
+ loginHandler = auth.NewLoginHandler(authService)
)
staticHandler, err := static.ServeStaticHandler()
@@ -32,10 +33,12 @@ func MountHandler(
mux := ext.NewRouter()
mux.AddMiddleware(ext.Compress)
+ mux.AddMiddleware(ext.Authenticate(authService))
mux.AddMiddleware(ext.Log)
mux.HandleFunc("/static/{file}", staticHandler)
mux.HandleFunc("/login/{$}", loginHandler.Login)
+ mux.HandleFunc("/logout/{$}", loginHandler.Logout)
mux.HandleFunc("/{name}/about/{$}", gitHandler.About)
mux.HandleFunc("/{name}/", gitHandler.Summary)
mux.HandleFunc("/{name}/refs/{$}", gitHandler.Refs)