From 3784181e4fad3c947dfa95081d8a0b34f5be12d4 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Wed, 11 Dec 2024 18:10:12 +0100 Subject: feat: Disable auth if passphrase is empty Disable all auth mechanism when passphrase is empty. That will allow for a simpler setup. --- pkg/ext/auth.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkg/ext') diff --git a/pkg/ext/auth.go b/pkg/ext/auth.go index bb6c0a2..b57e86a 100644 --- a/pkg/ext/auth.go +++ b/pkg/ext/auth.go @@ -11,6 +11,14 @@ type authService interface { ValidateToken(token []byte) (bool, error) } +func DisableAuthentication(next http.HandlerFunc) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + ctx = context.WithValue(ctx, "disableAuthentication", true) + next(w, r.WithContext(ctx)) + } +} + func Authenticate(auth authService) func(next http.HandlerFunc) http.HandlerFunc { return func(next http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { -- cgit v1.2.3