diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-12-11 18:10:12 +0100 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-12-11 18:10:12 +0100 |
commit | 3784181e4fad3c947dfa95081d8a0b34f5be12d4 (patch) | |
tree | 48263aa693149f997cdd7ac0c51bf0f994743748 /pkg/handler/router.go | |
parent | 57efc8d2173fdff1ef99157a2633d3f1d366a290 (diff) | |
download | cerrado-3784181e4fad3c947dfa95081d8a0b34f5be12d4.tar.gz cerrado-3784181e4fad3c947dfa95081d8a0b34f5be12d4.tar.bz2 cerrado-3784181e4fad3c947dfa95081d8a0b34f5be12d4.zip |
feat: Disable auth if passphrase is empty
Disable all auth mechanism when passphrase is empty. That will allow for
a simpler setup.
Diffstat (limited to 'pkg/handler/router.go')
-rw-r--r-- | pkg/handler/router.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/pkg/handler/router.go b/pkg/handler/router.go index ee4081b..82ee8fd 100644 --- a/pkg/handler/router.go +++ b/pkg/handler/router.go @@ -33,12 +33,17 @@ func MountHandler( mux := ext.NewRouter() mux.AddMiddleware(ext.Compress) - mux.AddMiddleware(ext.Authenticate(authService)) mux.AddMiddleware(ext.Log) + if configRepo.IsAuthEnabled() { + mux.AddMiddleware(ext.Authenticate(authService)) + mux.HandleFunc("/login/{$}", loginHandler.Login) + mux.HandleFunc("/logout/{$}", loginHandler.Logout) + } else { + mux.AddMiddleware(ext.DisableAuthentication) + } + 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) |