aboutsummaryrefslogtreecommitdiff
path: root/pkg/ext
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-12-11 18:10:12 +0100
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-12-11 18:10:12 +0100
commit3784181e4fad3c947dfa95081d8a0b34f5be12d4 (patch)
tree48263aa693149f997cdd7ac0c51bf0f994743748 /pkg/ext
parent57efc8d2173fdff1ef99157a2633d3f1d366a290 (diff)
downloadcerrado-3784181e4fad3c947dfa95081d8a0b34f5be12d4.tar.gz
cerrado-3784181e4fad3c947dfa95081d8a0b34f5be12d4.tar.bz2
cerrado-3784181e4fad3c947dfa95081d8a0b34f5be12d4.zip
feat: Disable auth if passphrase is empty
Disable all auth mechanism when passphrase is empty. That will allow for a simpler setup.
Diffstat (limited to 'pkg/ext')
-rw-r--r--pkg/ext/auth.go8
1 files changed, 8 insertions, 0 deletions
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) {