From 1e45ae2ea3497958b2ea6a20137955cfc3bbc964 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Wed, 11 Dec 2024 17:05:12 +0100 Subject: 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. --- pkg/handler/router.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg/handler/router.go') 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) -- cgit v1.2.3