1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From c0ad877023d4a519fd9c2995e9b623ef3656f789 Mon Sep 17 00:00:00 2001
From: "Katja Ramona Sophie Kwast (zaphyra)" <git@zaphyra.eu>
Date: Wed, 20 Aug 2025 09:56:49 +0200
Subject: [PATCH] cmd/gmuks: add flag to disable auth
---
cmd/gomuks/main.go | 11 +++++++++--
pkg/gomuks/server.go | 6 ++----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/cmd/gomuks/main.go b/cmd/gomuks/main.go
index e71a06f..be178b2 100644
--- a/cmd/gomuks/main.go
+++ b/cmd/gomuks/main.go
@@ -32,10 +32,14 @@ import (
var wantHelp, _ = flag.MakeHelpFlag()
var wantVersion = flag.MakeFull("v", "version", "View gomuks version and quit.", "false").Bool()
+var disableAuth = flag.MakeFull("d", "disable-auth", "Disable the basic-auth requested by the web-client", "false").Bool()
func main() {
- gomuks.PromptInput = readline.Line
- gomuks.PromptPassword = readline.Password
+ if !*disableAuth {
+ gomuks.PromptInput = readline.Line
+ gomuks.PromptPassword = readline.Password
+ }
+
hicli.InitialDeviceDisplayName = "gomuks web"
exhttp.AutoAllowCORS = false
flag.SetHelpTitles(
@@ -57,6 +61,9 @@ func main() {
}
gmx := gomuks.NewGomuks()
+ if *disableAuth {
+ gmx.DisableAuth = true
+ }
gmx.Version = version.Version
gmx.Commit = version.Commit
gmx.LinkifiedVersion = version.LinkifiedVersion
diff --git a/pkg/gomuks/server.go b/pkg/gomuks/server.go
index 100851b..3ffd127 100644
--- a/pkg/gomuks/server.go
+++ b/pkg/gomuks/server.go
@@ -245,10 +245,6 @@ func (gmx *Gomuks) writeTokenCookie(w http.ResponseWriter, created, jsonOutput,
}
func (gmx *Gomuks) Authenticate(w http.ResponseWriter, r *http.Request) {
- if gmx.DisableAuth {
- w.WriteHeader(http.StatusOK)
- return
- }
jsonOutput := r.URL.Query().Get("output") == "json"
allowPrompt := r.URL.Query().Get("no_prompt") != "true"
insecureCookie := r.URL.Query().Get("insecure_cookie") == "true"
@@ -256,6 +252,8 @@ func (gmx *Gomuks) Authenticate(w http.ResponseWriter, r *http.Request) {
if err == nil && gmx.validateAuth(authCookie.Value, false) {
hlog.FromRequest(r).Debug().Msg("Authentication successful with existing cookie")
gmx.writeTokenCookie(w, false, jsonOutput, insecureCookie)
+ } else if gmx.DisableAuth {
+ gmx.writeTokenCookie(w, true, jsonOutput, insecureCookie)
} else if found, correct := gmx.doBasicAuth(r); found && correct {
hlog.FromRequest(r).Debug().Msg("Authentication successful with username and password")
gmx.writeTokenCookie(w, true, jsonOutput, insecureCookie)
--
2.50.1