INNER CODE UNIT · Go

writeZeroTrustChallenge

netgoat-xyz/netgoat · main.go:1289

func writeZeroTrustChallenge(w http.ResponseWriter, store *challenge.Store, r *http.Request, binding challenge.SessionBinding) {
	ch := store.Create(binding)
	writeChallengeResponse(w, r, ch, http.StatusForbidden, "Zero-trust verification required")
}

func zeroTrustChallengeNeeded(store *challenge.Store, r *http.Request, result *auth.AuthResult, globalEnabled bool, binding challenge.SessionBinding) bool {
	return auth.RequireZeroTrustChallenge(result, globalEnabled, store.Satisfied(r, binding))
}

func writeChallengeResponse(w http.ResponseWriter, r *http.Request, ch *challenge.Challenge, status int, fallback string) {
	if challenge.WantsJSON(r) {
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(status)
		_, _ = w.Write(challenge.RenderChallengeJSON(ch, status, fallback))
		return
	}
	html := challenge.RenderDynamicErrorPage(ch, status, fallback)
	w.Header().Set("Content-Type", "text/html; charset=utf-8")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…