diff --git a/models/webhook.go b/models/webhook.go index cb5b5c7c972a9..7b7934595390a 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -658,7 +658,6 @@ func prepareWebhook(e Engine, w *Webhook, repo *Repository, event HookEventType, return fmt.Errorf("GetDingtalkPayload: %v", err) } default: - p.SetSecret(w.Secret) payloader = p } @@ -731,6 +730,8 @@ func (t *HookTask) deliver() { Header("X-Gitea-Event", string(t.EventType)). Header("X-Gitea-Signature", t.Signature). Header("X-Gogs-Delivery", t.UUID). + Header("X-Gogs-Signature", t.Signature). + Header("X-Hub-Signature", "sha256="+t.Signature). Header("X-Gogs-Event", string(t.EventType)). Header("X-Gogs-Signature", t.Signature). HeaderWithSensitiveCase("X-GitHub-Delivery", t.UUID). diff --git a/models/webhook_discord.go b/models/webhook_discord.go index 893e78096593c..8dbc55acaa89e 100644 --- a/models/webhook_discord.go +++ b/models/webhook_discord.go @@ -80,9 +80,6 @@ var ( failedColor = color("ff3232") ) -// SetSecret sets the discord secret -func (p *DiscordPayload) SetSecret(_ string) {} - // JSONPayload Marshals the DiscordPayload to json func (p *DiscordPayload) JSONPayload() ([]byte, error) { data, err := json.MarshalIndent(p, "", " ") diff --git a/models/webhook_slack.go b/models/webhook_slack.go index 90d5ccce0b7c1..07ef176246a5c 100644 --- a/models/webhook_slack.go +++ b/models/webhook_slack.go @@ -42,9 +42,6 @@ type SlackAttachment struct { Text string `json:"text"` } -// SetSecret sets the slack secret -func (p *SlackPayload) SetSecret(_ string) {} - // JSONPayload Marshals the SlackPayload to json func (p *SlackPayload) JSONPayload() ([]byte, error) { data, err := json.MarshalIndent(p, "", " ") diff --git a/vendor/code.gitea.io/sdk/gitea/hook.go b/vendor/code.gitea.io/sdk/gitea/hook.go index d36e4d4375ff9..3cec5d00684d4 100644 --- a/vendor/code.gitea.io/sdk/gitea/hook.go +++ b/vendor/code.gitea.io/sdk/gitea/hook.go @@ -133,7 +133,6 @@ func (c *Client) DeleteRepoHook(user, repo string, id int64) error { // Payloader payload is some part of one hook type Payloader interface { - SetSecret(string) JSONPayload() ([]byte, error) } @@ -194,7 +193,6 @@ var ( // CreatePayload FIXME type CreatePayload struct { - Secret string `json:"secret"` Sha string `json:"sha"` Ref string `json:"ref"` RefType string `json:"ref_type"` @@ -202,11 +200,6 @@ type CreatePayload struct { Sender *User `json:"sender"` } -// SetSecret modifies the secret of the CreatePayload -func (p *CreatePayload) SetSecret(secret string) { - p.Secret = secret -} - // JSONPayload return payload information func (p *CreatePayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") @@ -249,7 +242,6 @@ const ( // DeletePayload represents delete payload type DeletePayload struct { - Secret string `json:"secret"` Ref string `json:"ref"` RefType string `json:"ref_type"` PusherType PusherType `json:"pusher_type"` @@ -257,11 +249,6 @@ type DeletePayload struct { Sender *User `json:"sender"` } -// SetSecret modifies the secret of the DeletePayload -func (p *DeletePayload) SetSecret(secret string) { - p.Secret = secret -} - // JSONPayload implements Payload func (p *DeletePayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") @@ -276,17 +263,11 @@ func (p *DeletePayload) JSONPayload() ([]byte, error) { // ForkPayload represents fork payload type ForkPayload struct { - Secret string `json:"secret"` Forkee *Repository `json:"forkee"` Repo *Repository `json:"repository"` Sender *User `json:"sender"` } -// SetSecret modifies the secret of the ForkPayload -func (p *ForkPayload) SetSecret(secret string) { - p.Secret = secret -} - // JSONPayload implements Payload func (p *ForkPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") @@ -304,7 +285,6 @@ const ( // IssueCommentPayload represents a payload information of issue comment event. type IssueCommentPayload struct { - Secret string `json:"secret"` Action HookIssueCommentAction `json:"action"` Issue *Issue `json:"issue"` Comment *Comment `json:"comment"` @@ -313,11 +293,6 @@ type IssueCommentPayload struct { Sender *User `json:"sender"` } -// SetSecret modifies the secret of the IssueCommentPayload -func (p *IssueCommentPayload) SetSecret(secret string) { - p.Secret = secret -} - // JSONPayload implements Payload func (p *IssueCommentPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") @@ -342,18 +317,12 @@ const ( // ReleasePayload represents a payload information of release event. type ReleasePayload struct { - Secret string `json:"secret"` Action HookReleaseAction `json:"action"` Release *Release `json:"release"` Repository *Repository `json:"repository"` Sender *User `json:"sender"` } -// SetSecret modifies the secret of the ReleasePayload -func (p *ReleasePayload) SetSecret(secret string) { - p.Secret = secret -} - // JSONPayload implements Payload func (p *ReleasePayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") @@ -368,7 +337,6 @@ func (p *ReleasePayload) JSONPayload() ([]byte, error) { // PushPayload represents a payload information of push event. type PushPayload struct { - Secret string `json:"secret"` Ref string `json:"ref"` Before string `json:"before"` After string `json:"after"` @@ -380,11 +348,6 @@ type PushPayload struct { Sender *User `json:"sender"` } -// SetSecret modifies the secret of the PushPayload -func (p *PushPayload) SetSecret(secret string) { - p.Secret = secret -} - // JSONPayload FIXME func (p *PushPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") @@ -448,7 +411,6 @@ const ( // IssuePayload represents the payload information that is sent along with an issue event. type IssuePayload struct { - Secret string `json:"secret"` Action HookIssueAction `json:"action"` Index int64 `json:"number"` Changes *ChangesPayload `json:"changes,omitempty"` @@ -457,11 +419,6 @@ type IssuePayload struct { Sender *User `json:"sender"` } -// SetSecret modifies the secret of the IssuePayload. -func (p *IssuePayload) SetSecret(secret string) { - p.Secret = secret -} - // JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces. func (p *IssuePayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") @@ -487,7 +444,6 @@ type ChangesPayload struct { // PullRequestPayload represents a payload information of pull request event. type PullRequestPayload struct { - Secret string `json:"secret"` Action HookIssueAction `json:"action"` Index int64 `json:"number"` Changes *ChangesPayload `json:"changes,omitempty"` @@ -496,11 +452,6 @@ type PullRequestPayload struct { Sender *User `json:"sender"` } -// SetSecret modifies the secret of the PullRequestPayload. -func (p *PullRequestPayload) SetSecret(secret string) { - p.Secret = secret -} - // JSONPayload FIXME func (p *PullRequestPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") @@ -525,18 +476,12 @@ const ( // RepositoryPayload payload for repository webhooks type RepositoryPayload struct { - Secret string `json:"secret"` Action HookRepoAction `json:"action"` Repository *Repository `json:"repository"` Organization *User `json:"organization"` Sender *User `json:"sender"` } -// SetSecret modifies the secret of the RepositoryPayload -func (p *RepositoryPayload) SetSecret(secret string) { - p.Secret = secret -} - // JSONPayload JSON representation of the payload func (p *RepositoryPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ")