mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 21:57:29 +08:00
fix webui white screen: persist token via cookie for asset/api auth
This commit is contained in:
@@ -133,6 +133,16 @@ func (s *RegistryServer) handleWebUI(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
if s.token != "" {
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: "clawgo_webui_token",
|
||||
Value: s.token,
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
MaxAge: 86400,
|
||||
})
|
||||
}
|
||||
if s.tryServeWebUIDist(w, r, "/webui/index.html") {
|
||||
return
|
||||
}
|
||||
@@ -372,6 +382,9 @@ func (s *RegistryServer) checkAuth(r *http.Request) bool {
|
||||
if strings.TrimSpace(r.URL.Query().Get("token")) == s.token {
|
||||
return true
|
||||
}
|
||||
if c, err := r.Cookie("clawgo_webui_token"); err == nil && strings.TrimSpace(c.Value) == s.token {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user