prometheus-fail2ban-exporter/server/auth.go

18 lines
395 B
Go
Raw Permalink Normal View History

2023-10-02 10:50:34 +00:00
package server
import (
"net/http"
"git.cryptic.systems/volker.raschek/prometheus-fail2ban-exporter/auth"
)
func AuthMiddleware(handlerFunc http.HandlerFunc, authProvider auth.AuthProvider) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if authProvider.IsAllowed(r) {
handlerFunc.ServeHTTP(w, r)
} else {
w.WriteHeader(http.StatusUnauthorized)
}
}
}