You've already forked prometheus-fail2ban-exporter
This commit is contained in:
17
server/auth.go
Normal file
17
server/auth.go
Normal file
@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user