mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 06:43:34 +01:00
webhook deliver: keep Bearer prefix in history
This commit is contained in:
parent
36f05e6f4e
commit
5d45545ca1
2 changed files with 8 additions and 2 deletions
|
@ -78,7 +78,13 @@ func Deliver(ctx context.Context, t *webhook_model.HookTask) error {
|
|||
}
|
||||
if 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{
|
||||
|
|
|
@ -132,7 +132,7 @@ func TestWebhookDeliverAuthorizationHeader(t *testing.T) {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue