mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-21 00:11:42 +02:00
refactor(middleware): emit OIDC blocked event at specific error points
This commit is contained in:
@@ -119,8 +119,10 @@ func (amw *oidcMiddleware) before(w http.ResponseWriter, r *http.Request) (proce
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Method != http.MethodHead {
|
emitBlockedEvent := func() {
|
||||||
defer httpevents.Blocked(r, "OIDC", err.Error())
|
if r.Method != http.MethodHead {
|
||||||
|
httpevents.Blocked(r, "OIDC", err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isGet := r.Method == http.MethodGet
|
isGet := r.Method == http.MethodGet
|
||||||
@@ -135,11 +137,13 @@ func (amw *oidcMiddleware) before(w http.ResponseWriter, r *http.Request) (proce
|
|||||||
reqType = "WebSocket"
|
reqType = "WebSocket"
|
||||||
}
|
}
|
||||||
OIDC.LogWarn(r).Msgf("[OIDC] %s request blocked.\nConsider adding bypass rule for this path if needed", reqType)
|
OIDC.LogWarn(r).Msgf("[OIDC] %s request blocked.\nConsider adding bypass rule for this path if needed", reqType)
|
||||||
|
emitBlockedEvent()
|
||||||
return false
|
return false
|
||||||
case errors.Is(err, auth.ErrMissingOAuthToken):
|
case errors.Is(err, auth.ErrMissingOAuthToken):
|
||||||
amw.auth.HandleAuth(w, r)
|
amw.auth.HandleAuth(w, r)
|
||||||
default:
|
default:
|
||||||
auth.WriteBlockPage(w, http.StatusForbidden, err.Error(), "Logout", auth.OIDCLogoutPath)
|
auth.WriteBlockPage(w, http.StatusForbidden, err.Error(), "Logout", auth.OIDCLogoutPath)
|
||||||
|
emitBlockedEvent()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user