From 6257253267f819d79127791c051d474232e3208f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Fri=C4=8D?= Date: Fri, 16 Jan 2026 20:08:31 +0100 Subject: [PATCH 1/3] feat: add option to disable authentication --- README.md | 1 + application/backend/.env example | 2 +- application/backend/app/routes/routes.go | 29 +++++++++++++++---- application/frontend/index.html | 4 +++ .../src/lib/ClientPanel/ClientPanel.svelte | 4 +++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 40fb1d6..3f1a6fe 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ Once done, just go to and login as "admin" with . | HOST | Url to OnLogs host from protocol to domain name. | | if `AGENT=true` | ONLOGS_TOKEN | Token that will use an agent to authorize and connect to HOST | Generates with OnLogs interface | if `AGENT=true` | MAX_LOGS_SIZE | Maximum allowed total logs size before cleanup triggers. Accepts human-readable formats like 5GB, 500MB, 1.5GB etc. When exceeded, 10% of logs (by count) will be removed proportionally across containers starting from oldest | 10GB | - +| DISABLE_AUTH | Option to completely disable built in authentication in the application. When this option is set to `true` the app will behave like if the Administrator is logged in. The option to manage users will be removed. | false | - ### Docket socket URL By default the app will connect using the raw unix socket. But this can be overriden via the ENV variable `DOCKER_HOST`. That way you can specify fully qualified URL to the socket or URL of an docker socket proxy. diff --git a/application/backend/.env example b/application/backend/.env example index 4ad1c5b..13a76ed 100644 --- a/application/backend/.env example +++ b/application/backend/.env example @@ -2,6 +2,6 @@ PASSWORD=fsadfsadfad ENV_NAME = local PORT=2874 ONLOGS_PATH_PREFIX='' - +DISABLE_AUTH=false # HOST=onlogs.coposter.me # AGENT=true \ No newline at end of file diff --git a/application/backend/app/routes/routes.go b/application/backend/app/routes/routes.go index e675d44..dcce55a 100644 --- a/application/backend/app/routes/routes.go +++ b/application/backend/app/routes/routes.go @@ -43,6 +43,10 @@ func enableCors(w *http.ResponseWriter) { } func verifyAdminUser(w *http.ResponseWriter, req *http.Request) bool { + if os.Getenv("DISABLE_AUTH") == "true" { + return true + } + username, err := util.GetUserFromJWT(*req) if username != os.Getenv("ADMIN_USERNAME") { (*w).WriteHeader(http.StatusForbidden) @@ -59,6 +63,10 @@ func verifyAdminUser(w *http.ResponseWriter, req *http.Request) bool { } func verifyUser(w *http.ResponseWriter, req *http.Request) bool { + if os.Getenv("DISABLE_AUTH") == "true" { + return true + } + _, err := util.GetUserFromJWT(*req) if err != nil { (*w).WriteHeader(http.StatusUnauthorized) @@ -91,19 +99,30 @@ func (h *RouteController)Frontend(w http.ResponseWriter, req *http.Request) { if err != nil { dir = http.Dir("dist") file, err = dir.Open("index.html") + fileName = "index.html" } if err != nil { return } defer file.Close() + stat, _ := file.Stat() + content, _ := io.ReadAll(file) + + if fileName == "index.html" { + var disableAuth []byte + if os.Getenv("DISABLE_AUTH") == "true" { + disableAuth = []byte("true") + } else { + disableAuth = []byte("false") + } + + content = bytes.Replace(content, []byte("$DISABLE_AUTH$"), disableAuth, 1) + } + w.Header().Set("Cache-Control", "no-store") w.Header().Set("Content-Type", mime.TypeByExtension(filepath.Ext(fileName))) - - stat, _ := file.Stat() - content := make([]byte, stat.Size()) - io.ReadFull(file, content) - http.ServeContent(w, req, requestedPath, stat.ModTime(), bytes.NewReader(content)) + http.ServeContent(w, req, fileName, stat.ModTime(), bytes.NewReader(content)) } func (h *RouteController)CheckCookie(w http.ResponseWriter, req *http.Request) { diff --git a/application/frontend/index.html b/application/frontend/index.html index 1739d85..a46b8a3 100644 --- a/application/frontend/index.html +++ b/application/frontend/index.html @@ -26,6 +26,10 @@ OnLogs + +
diff --git a/application/frontend/src/lib/ClientPanel/ClientPanel.svelte b/application/frontend/src/lib/ClientPanel/ClientPanel.svelte index 71188b9..2949291 100644 --- a/application/frontend/src/lib/ClientPanel/ClientPanel.svelte +++ b/application/frontend/src/lib/ClientPanel/ClientPanel.svelte @@ -14,6 +14,8 @@ let localTheme = ""; let api = new fetchApi(); + const showUserMenu = window.DISABLE_AUTH ?? true; + //store management function toggleUserMenu() { userMenuOpen.update((v) => !v); @@ -69,6 +71,7 @@ ($activeMenuOption === 'view' && 'active')}" /> + {#if showUserMenu}
  • + {/if}