Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOsman İlge Ünaldı <o.unaldi@etu.edu.tr>2022-03-15 02:22:02 +0300
committerJaime Martinez <jmartinez@gitlab.com>2022-03-15 02:22:02 +0300
commit0a2122d4960ebdca71a21cdb6038696f1746c3f1 (patch)
tree71e5a6dd68c4b7b75a76f6dac89ea1a6bafe06bf /internal/auth
parentfa999c136de21d230f1f7b2f92ce281825ceacb3 (diff)
feat: allow auth http.Client timeout to be configurable
Changelog: added
Diffstat (limited to 'internal/auth')
-rw-r--r--internal/auth/auth.go4
-rw-r--r--internal/auth/auth_test.go3
2 files changed, 4 insertions, 3 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go
index 45b77b4f..a6e1f7e7 100644
--- a/internal/auth/auth.go
+++ b/internal/auth/auth.go
@@ -660,7 +660,7 @@ func generateKeys(secret string, count int) ([][]byte, error) {
}
// New when authentication supported this will be used to create authentication handler
-func New(pagesDomain, storeSecret, clientID, clientSecret, redirectURI, internalGitlabServer, publicGitlabServer, authScope string) (*Auth, error) {
+func New(pagesDomain, storeSecret, clientID, clientSecret, redirectURI, internalGitlabServer, publicGitlabServer, authScope string, authTimeout time.Duration) (*Auth, error) {
// generate 3 keys, 2 for the cookie store and 1 for JWT signing
keys, err := generateKeys(storeSecret, 3)
if err != nil {
@@ -675,7 +675,7 @@ func New(pagesDomain, storeSecret, clientID, clientSecret, redirectURI, internal
internalGitlabServer: strings.TrimRight(internalGitlabServer, "/"),
publicGitlabServer: strings.TrimRight(publicGitlabServer, "/"),
apiClient: &http.Client{
- Timeout: 5 * time.Second,
+ Timeout: authTimeout,
Transport: httptransport.DefaultTransport,
},
store: sessions.NewCookieStore(keys[0], keys[1]),
diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go
index 61b4e88a..4b035132 100644
--- a/internal/auth/auth_test.go
+++ b/internal/auth/auth_test.go
@@ -10,6 +10,7 @@ import (
"net/url"
"strings"
"testing"
+ "time"
"github.com/golang/mock/gomock"
"github.com/gorilla/sessions"
@@ -30,7 +31,7 @@ func createTestAuth(t *testing.T, internalServer string, publicServer string) *A
"http://pages.gitlab-example.com/auth",
internalServer,
publicServer,
- "scope")
+ "scope", 5*time.Second)
require.NoError(t, err)