mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-25 11:16:11 +01:00
webhook deliver: keep Bearer prefix in history
This commit is contained in:
parent
36f05e6f4e
commit
5d45545ca1
|
@ -78,7 +78,13 @@ func Deliver(ctx context.Context, t *webhook_model.HookTask) error {
|
||||||
}
|
}
|
||||||
if authorization != "" {
|
if authorization != "" {
|
||||||
req.Header.Set("Authorization", authorization)
|
req.Header.Set("Authorization", authorization)
|
||||||
t.RequestInfo.Headers["Authorization"] = "******"
|
redacted := "******"
|
||||||
|
if strings.HasPrefix(authorization, "Bearer ") {
|
||||||
|
redacted = "Bearer " + redacted
|
||||||
|
} else if strings.HasPrefix(authorization, "Basic ") {
|
||||||
|
redacted = "Basic " + redacted
|
||||||
|
}
|
||||||
|
t.RequestInfo.Headers["Authorization"] = redacted
|
||||||
}
|
}
|
||||||
|
|
||||||
t.ResponseInfo = &webhook_model.HookResponse{
|
t.ResponseInfo = &webhook_model.HookResponse{
|
||||||
|
|
|
@ -132,7 +132,7 @@ func TestWebhookDeliverAuthorizationHeader(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.True(t, hookTask.IsSucceed)
|
assert.True(t, hookTask.IsSucceed)
|
||||||
assert.Equal(t, "******", hookTask.RequestInfo.Headers["Authorization"])
|
assert.Equal(t, "Bearer ******", hookTask.RequestInfo.Headers["Authorization"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWebhookDeliverHookTask(t *testing.T) {
|
func TestWebhookDeliverHookTask(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue