auth-proxy: reusable ingress with auth proxy object for cue configs (#113)
affects: #110
Creates reusable auth proxy object in base cue config, and migrates rpuppy, url-shortener, pihole and memberships app to it.
Memberships app always requires authentication.
url-shortener now supports non-auth based interactions.
diff --git a/apps/url-shortener/main.go b/apps/url-shortener/main.go
index bb805e4..23365fd 100644
--- a/apps/url-shortener/main.go
+++ b/apps/url-shortener/main.go
@@ -19,6 +19,9 @@
var port = flag.Int("port", 8080, "Port to listen on")
var dbPath = flag.String("db-path", "url-shortener.db", "Path to the SQLite file")
+var requireAuth = flag.Bool("require-auth", false, "If false there won't be made any distinctions between users")
+
+const anyUser = "__any__"
//go:embed index.html
var indexHTML embed.FS
@@ -157,6 +160,9 @@
}
func getLoggedInUser(r *http.Request) (string, error) {
+ if !*requireAuth {
+ return anyUser, nil
+ }
if user := r.Header.Get("X-User"); user != "" {
return user, nil
} else {