Markus Pesch
3998f9e2c2
All checks were successful
continuous-integration/drone/push Build is passing
18 lines
395 B
Go
18 lines
395 B
Go
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)
|
|
}
|
|
}
|
|
}
|