mirror of
https://github.com/ncarlier/webhookd.git
synced 2025-04-12 17:47:30 +00:00
fix(auth): add x_webauth_user to hook context
This commit is contained in:
parent
6a2cf96e95
commit
3cfb6c9044
|
@ -12,9 +12,9 @@ const xWebAuthUser = "X-WebAuth-User"
|
||||||
func AuthN(authenticator auth.Authenticator) Middleware {
|
func AuthN(authenticator auth.Authenticator) Middleware {
|
||||||
return func(next http.Handler) http.Handler {
|
return func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Del(xWebAuthUser)
|
r.Header.Del(xWebAuthUser)
|
||||||
if ok, username := authenticator.Validate(r); ok {
|
if ok, username := authenticator.Validate(r); ok {
|
||||||
w.Header().Set(xWebAuthUser, username)
|
r.Header.Set(xWebAuthUser, username)
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user