add a new configuration section for HTTP clients

HTTP clients are used for executing hooks such as the ones used for custom
actions, external authentication and pre-login user modifications.

This allows, for example, to use self-signed certificate without defeating the
purpose of using TLS
This commit is contained in:
Nicola Murino
2020-04-26 23:29:09 +02:00
parent ebd6a11f3a
commit d377181b25
16 changed files with 138 additions and 36 deletions

View File

@@ -8,7 +8,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"os"
"os/exec"
@@ -17,6 +16,7 @@ import (
"time"
"github.com/drakkan/sftpgo/dataprovider"
"github.com/drakkan/sftpgo/httpclient"
"github.com/drakkan/sftpgo/logger"
"github.com/drakkan/sftpgo/metrics"
"github.com/drakkan/sftpgo/utils"
@@ -509,9 +509,7 @@ func executeAction(a actionNotification) error {
return err
}
startTime := time.Now()
httpClient := &http.Client{
Timeout: 15 * time.Second,
}
httpClient := httpclient.GetHTTPClient()
resp, err := httpClient.Post(url.String(), "application/json", bytes.NewBuffer(a.AsJSON()))
respCode := 0
if err == nil {