Repository: minio/minio (language: go)

Issue:
Webhook HEAD request missing authorisation token
<!--- Provide a general summary of the issue in the Title above -->
When creating a Notification Endpoint and using the WebhookNotification Endpoint with auth token the HEAD requests from the MinIO server does not include the authorisation token.

## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
The HEAD request from MinIO server does not include the authorisation token configured in WebhookNotification Endpoint. 
<!--- If you're suggesting a change/improvement, tell us how it should work -->

## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
The HEAD request from MinIO server does not include the authorisation token configured in WebhookNotification Endpoint. 
<!--- If suggesting a change/improvement, explain the difference from current behavior -->

## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
Include authorisation token in the same way as for POST requests.
<!--- or ideas how to implement the addition or change -->

## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
Example setup with docker compose and echo server [https://github.com/flow-lab/minio-webhook-head](https://github.com/flow-lab/minio-webhook-head)
<!--- reproduce this bug. Include code to reproduce, if relevant -->
<!--- and make sure you have followed https://github.com/minio/minio/tree/release/docs/debugging to capture relevant logs -->

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

## Regression
<!-- Is this issue a regression? (Yes / No) -->
<!-- If Yes, optionally please include minio version or commit id or PR# that caused this regression, if you have these details. -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used (`minio --version`):
* Server setup and configuration:
* Operating System and version (`uname -a`):



Discussion / hints:
@kgrodzicki this is not an issue per se. I don't this how this affected you.
@kgrodzicki The HEAD requests are just to confirm there is a network connection. I will add a PR with the change and we can discuss if we need it there.
I presume this is just to clean up some error reported?

Fix patch:
diff --git a/internal/event/target/webhook.go b/internal/event/target/webhook.go
index 244df29ff083a..e3eed5e240e12 100644
--- a/internal/event/target/webhook.go
+++ b/internal/event/target/webhook.go
@@ -119,10 +119,17 @@ func (target *WebhookTarget) IsActive() (bool, error) {
 		}
 		return false, err
 	}
+	tokens := strings.Fields(target.args.AuthToken)
+	switch len(tokens) {
+	case 2:
+		req.Header.Set("Authorization", target.args.AuthToken)
+	case 1:
+		req.Header.Set("Authorization", "Bearer "+target.args.AuthToken)
+	}
 
 	resp, err := target.httpClient.Do(req)
 	if err != nil {
-		if xnet.IsNetworkOrHostDown(err, false) || errors.Is(err, context.DeadlineExceeded) {
+		if xnet.IsNetworkOrHostDown(err, true) {
 			return false, errNotConnected
 		}
 		return false, err
@@ -133,7 +140,8 @@ func (target *WebhookTarget) IsActive() (bool, error) {
 	return true, nil
 }
 
-// Save - saves the events to the store if queuestore is configured, which will be replayed when the wenhook connection is active.
+// Save - saves the events to the store if queuestore is configured,
+// which will be replayed when the webhook connection is active.
 func (target *WebhookTarget) Save(eventData event.Event) error {
 	if target.store != nil {
 		return target.store.Put(eventData)


Test patch: