diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-14 11:09:39 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-14 11:09:39 -0800 |
| commit | 4d55202300f9648bdcf9be14aeb2b8034ca37fc3 (patch) | |
| tree | c77f662cac74dc7b36a355ad78e85029b045049f /web/web.go | |
| parent | b47721a02d3fdfb1b6a565df29c85e7c51d8c490 (diff) | |
| download | neko-4d55202300f9648bdcf9be14aeb2b8034ca37fc3.tar.gz neko-4d55202300f9648bdcf9be14aeb2b8034ca37fc3.tar.bz2 neko-4d55202300f9648bdcf9be14aeb2b8034ca37fc3.zip | |
feat: fix authentication to handle no-password scenario\n\n- Updated Authenticated() to return true when no password is configured\n- Updated apiLoginHandler to succeed when no password is set\n- Added comprehensive backend tests for both password/no-password cases\n- Added E2E tests for authentication flows (password tests are skipped by default)\n- All tests pass for both authentication scenarios\n\nFixes issue where app would require login even when no password was configured.\nNow properly supports passwordless mode for local development.
Diffstat (limited to 'web/web.go')
| -rw-r--r-- | web/web.go | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -133,6 +133,11 @@ func logoutHandler(w http.ResponseWriter, r *http.Request) { } func Authenticated(r *http.Request) bool { + // If no password is configured, authentication is not required + if config.Config.DigestPassword == "" { + return true + } + pc, err := r.Cookie("auth") if err != nil { return false @@ -179,6 +184,17 @@ func apiLoginHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) return } + + // If no password is configured, authentication is not required + if config.Config.DigestPassword == "" { + // Still set a dummy auth cookie for consistency + c := http.Cookie{Name: AuthCookie, Value: "noauth", Path: "/", MaxAge: SecondsInAYear, HttpOnly: true} + http.SetCookie(w, &c) + w.Header().Set("Content-Type", "application/json") + fmt.Fprintf(w, `{"status":"ok"}`) + return + } + username := r.FormValue("username") password := r.FormValue("password") |
