This commit is contained in:
pavel 2026-05-15 17:40:09 +02:00
commit 07522043b4
16 changed files with 870 additions and 38 deletions

View file

@ -38,6 +38,12 @@ func (a *App) handleDeployWebhook(w http.ResponseWriter, r *http.Request) {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
userToken := strings.TrimSpace(r.URL.Query().Get("ut"))
ok, err := a.validateUserWebhookToken(r.Context(), p.UserID, userToken)
if err != nil || !ok {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
ref, err := parseWebhookRef(r)
if err != nil {
http.Error(w, "invalid webhook payload", http.StatusBadRequest)
@ -98,7 +104,11 @@ func (a *App) getProjectForWebhook(ctx context.Context, projectID int64, token s
}
return Project{}, err
}
p.WebhookURL = a.deployWebhookURL(p.ID, p.DeployToken)
tok, err := a.ensureUserWebhookToken(ctx, p.UserID)
if err != nil {
return Project{}, err
}
p.WebhookURL = a.deployWebhookURL(p.ID, p.DeployToken, tok.Token)
return p, nil
}