Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions management/server/idp/auth0.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ func NewAuth0Manager(config Auth0ClientConfig, appMetrics telemetry.AppMetrics)
httpTransport := http.DefaultTransport.(*http.Transport).Clone()
httpTransport.MaxIdleConns = 5

httpClient := &http.Client{
Timeout: 10 * time.Second,
httpClient := &http.Client{
Timeout: idpTimeout(),
Transport: httpTransport,
}

helper := JsonParser{}

if config.AuthIssuer == "" {
Expand Down
7 changes: 3 additions & 4 deletions management/server/idp/authentik.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ type AuthentikCredentials struct {
}

// NewAuthentikManager creates a new instance of the AuthentikManager.
func NewAuthentikManager(config AuthentikClientConfig,
appMetrics telemetry.AppMetrics) (*AuthentikManager, error) {
func NewAuthentikManager(config AuthentikClientConfig, appMetrics telemetry.AppMetrics) (*AuthentikManager, error) {
httpTransport := http.DefaultTransport.(*http.Transport).Clone()
httpTransport.MaxIdleConns = 5

httpClient := &http.Client{
Timeout: 10 * time.Second,
Timeout: idpTimeout(),
Transport: httpTransport,
}

helper := JsonParser{}

if config.ClientID == "" {
Expand Down
5 changes: 3 additions & 2 deletions management/server/idp/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ func NewAzureManager(config AzureClientConfig, appMetrics telemetry.AppMetrics)
httpTransport := http.DefaultTransport.(*http.Transport).Clone()
httpTransport.MaxIdleConns = 5

httpClient := &http.Client{
Timeout: 10 * time.Second,
httpClient := &http.Client{
Timeout: idpTimeout(),
Transport: httpTransport,
}

helper := JsonParser{}

if config.ClientID == "" {
Expand Down
4 changes: 2 additions & 2 deletions management/server/idp/google_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/base64"
"fmt"
"net/http"
"time"

log "github.com/sirupsen/logrus"
"golang.org/x/oauth2/google"
Expand Down Expand Up @@ -49,9 +48,10 @@ func NewGoogleWorkspaceManager(ctx context.Context, config GoogleWorkspaceClient
httpTransport.MaxIdleConns = 5

httpClient := &http.Client{
Timeout: 10 * time.Second,
Timeout: idpTimeout(),
Transport: httpTransport,
}

helper := JsonParser{}

if config.CustomerID == "" {
Expand Down
4 changes: 2 additions & 2 deletions management/server/idp/jumpcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"net/http"
"strings"
"time"

v1 "github.com/TheJumpCloud/jcapi-go/v1"

Expand Down Expand Up @@ -46,9 +45,10 @@ func NewJumpCloudManager(config JumpCloudClientConfig, appMetrics telemetry.AppM
httpTransport.MaxIdleConns = 5

httpClient := &http.Client{
Timeout: 10 * time.Second,
Timeout: idpTimeout(),
Transport: httpTransport,
}

helper := JsonParser{}

if config.APIToken == "" {
Expand Down
3 changes: 2 additions & 1 deletion management/server/idp/keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ func NewKeycloakManager(config KeycloakClientConfig, appMetrics telemetry.AppMet
httpTransport.MaxIdleConns = 5

httpClient := &http.Client{
Timeout: 10 * time.Second,
Timeout: idpTimeout(),
Transport: httpTransport,
}

helper := JsonParser{}

if config.ClientID == "" {
Expand Down
3 changes: 1 addition & 2 deletions management/server/idp/okta.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"
"net/url"
"strings"
"time"

"github.com/okta/okta-sdk-golang/v2/okta"
"github.com/okta/okta-sdk-golang/v2/okta/query"
Expand Down Expand Up @@ -45,7 +44,7 @@ func NewOktaManager(config OktaClientConfig, appMetrics telemetry.AppMetrics) (*
httpTransport.MaxIdleConns = 5

httpClient := &http.Client{
Timeout: 10 * time.Second,
Timeout: idpTimeout(),
Transport: httpTransport,
}

Expand Down
4 changes: 2 additions & 2 deletions management/server/idp/pocketid.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/url"
"slices"
"strings"
"time"

"github.com/netbirdio/netbird/management/server/telemetry"
)
Expand Down Expand Up @@ -88,9 +87,10 @@ func NewPocketIdManager(config PocketIdClientConfig, appMetrics telemetry.AppMet
httpTransport.MaxIdleConns = 5

httpClient := &http.Client{
Timeout: 10 * time.Second,
Timeout: idpTimeout(),
Transport: httpTransport,
}

helper := JsonParser{}

if config.ManagementEndpoint == "" {
Expand Down
23 changes: 23 additions & 0 deletions management/server/idp/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"encoding/json"
"math/rand"
"net/url"
"os"
"strings"
"time"
)

var (
Expand Down Expand Up @@ -69,3 +71,24 @@ func baseURL(rawURL string) string {

return parsedURL.Scheme + "://" + parsedURL.Host
}

// Provides the env variable name for use with idpTimeout function
const (
idpTimeoutEnv = "NETBIRD_IDP_TIMEOUT"
)

// idpTimmeout returns a timeout value for the IDP
func idpTimeout() time.Duration {
timeoutStr, ok := os.LookupEnv(idpTimeoutEnv)
if !ok || timeoutStr == "" {
defaultTimeout, _ := time.ParseDuration("10s")
return defaultTimeout
}

timeout, err := time.ParseDuration(timeoutStr)
if err != nil {
defaultTimeout, _ := time.ParseDuration("10s")
return defaultTimeout
}
return timeout
}
3 changes: 2 additions & 1 deletion management/server/idp/zitadel.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ func NewZitadelManager(config ZitadelClientConfig, appMetrics telemetry.AppMetri
httpTransport.MaxIdleConns = 5

httpClient := &http.Client{
Timeout: 10 * time.Second,
Timeout: idpTimeout(),
Transport: httpTransport,
}

helper := JsonParser{}

hasPAT := config.PAT != ""
Expand Down
Loading