-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Webhook + Add X-Hub-Signature #16176
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
96a3f78
Removed unneeded webhook related fields.
KN4CK3R 84e3ddc
Removed signature field.
KN4CK3R 98a2a8e
Fixed migration.
KN4CK3R 07e3c3d
Use string and int.
KN4CK3R bcbd291
Removed secret from payload.
KN4CK3R 3d83b19
Merge branch 'main' of https://github.com/go-gitea/gitea into refacto…
KN4CK3R d4bdaa7
Merge branch 'main' of https://github.com/go-gitea/gitea into refacto…
KN4CK3R 784e8a0
Merge branch 'main' into refactor-webhook
techknowlogick 68be93f
Merge branch 'main' of https://github.com/go-gitea/gitea into refacto…
KN4CK3R a86a45a
Merge branch 'main' into refactor-webhook
zeripath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2021 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import ( | ||
"xorm.io/xorm" | ||
) | ||
|
||
func dropWebhookColumns(x *xorm.Engine) error { | ||
// Make sure the columns exist before dropping them | ||
type Webhook struct { | ||
Signature string `xorm:"TEXT"` | ||
IsSSL bool `xorm:"is_ssl"` | ||
} | ||
if err := x.Sync2(new(Webhook)); err != nil { | ||
return err | ||
} | ||
|
||
type HookTask struct { | ||
Typ string `xorm:"VARCHAR(16) index"` | ||
URL string `xorm:"TEXT"` | ||
Signature string `xorm:"TEXT"` | ||
HTTPMethod string `xorm:"http_method"` | ||
ContentType int | ||
IsSSL bool | ||
} | ||
if err := x.Sync2(new(HookTask)); err != nil { | ||
return err | ||
} | ||
|
||
sess := x.NewSession() | ||
defer sess.Close() | ||
if err := sess.Begin(); err != nil { | ||
return err | ||
} | ||
if err := dropTableColumns(sess, "webhook", "signature", "is_ssl"); err != nil { | ||
return err | ||
} | ||
if err := dropTableColumns(sess, "hook_task", "typ", "url", "signature", "http_method", "content_type", "is_ssl"); err != nil { | ||
return err | ||
} | ||
|
||
return sess.Commit() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know why this columns should be dropped? webhook maybe changed after hook_task finished. So these columns will keep the original information when requesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Webhook:
Signature
andIsSSL
are never usedHookTask:
Typ
see #16176 (comment)URL
moved toHookRequest
Signature
calculated on delivery. Is saved indirect in theHeader
map inHookRequest
HTTPMethod
moved toHookRequest
ContentType
of the Webhook is used on delivery. If the Webhook gets changed before sending the HookTask will use the current/correct settings. The original value is not available after a change but it's not visible on the UI anyway.IsSSL
is never used