Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase read time out for Guard #343

Merged
merged 1 commit into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion auth/providers/azure/graph/aks_tokenprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ type aksTokenProvider struct {
// NewAKSTokenProvider returns a TokenProvider that implements On-Behalf-Of flow using AKS first party service
func NewAKSTokenProvider(tokenURL, tenantID string) TokenProvider {
tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
Proxy: http.ProxyFromEnvironment,
MaxIdleConnsPerHost: 100,
}
return &aksTokenProvider{
name: "AKSTokenProvider",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ type clientCredentialTokenProvider struct {
// https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#get-a-token
func NewClientCredentialTokenProvider(clientID, clientSecret, loginURL, scope string) TokenProvider {
tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
Proxy: http.ProxyFromEnvironment,
MaxIdleConnsPerHost: 100,
}
return &clientCredentialTokenProvider{
name: "ClientCredentialTokenProvider",
Expand Down
3 changes: 2 additions & 1 deletion auth/providers/azure/graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func (u *UserInfo) getGroupIDs(userPrincipal string) ([]string, error) {
// Set the auth headers for the request
req.Header = u.headers
tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
Proxy: http.ProxyFromEnvironment,
MaxIdleConnsPerHost: 100,
}

u.client.Transport = tr
Expand Down
3 changes: 2 additions & 1 deletion auth/providers/azure/graph/obo_tokenprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ type oboTokenProvider struct {
// https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow
func NewOBOTokenProvider(clientID, clientSecret, loginURL, scope string) TokenProvider {
tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
Proxy: http.ProxyFromEnvironment,
MaxIdleConnsPerHost: 100,
}
return &oboTokenProvider{
name: "OBOTokenProvider",
Expand Down
5 changes: 3 additions & 2 deletions authz/providers/azure/rbac/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -280,7 +280,8 @@ func (a *AccessInfo) CheckAccess(request *authzv1.SubjectAccessReviewSpec) (*aut
a.setReqHeaders(req)

tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
Proxy: http.ProxyFromEnvironment,
MaxIdleConnsPerHost: 100,
}

a.client.Transport = tr
Expand Down
1 change: 1 addition & 0 deletions docs/reference/guard_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ guard run [flags]
--max-clock-skew duration Max acceptable clock skew for server clock (default 2m0s)
--ntp-server string Address of NTP serer used to check clock skew (default "0.pool.ntp.org")
--server-write-timeout Guard http server write timeout. Default is 10 seconds.
--server-read-timeout Guard http server read timeout. Default is 5 seconds.
--secure-addr string host:port used to serve secure apis (default ":8443")
--tls-ca-file string File containing CA certificate
--tls-cert-file string File container server TLS certificate
Expand Down
4 changes: 3 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ type Server struct {
AuthzRecommendedOptions *AuthzRecommendedOptions
TokenAuthenticator *token.Authenticator
WriteTimeout time.Duration
ReadTimeout time.Duration
}

func (s *Server) AddFlags(fs *pflag.FlagSet) {
fs.DurationVar(&s.WriteTimeout, "server-write-timeout", 10*time.Second, "Guard http server write timeout. Default is 10 seconds.")
fs.DurationVar(&s.ReadTimeout, "server-read-timeout", 5*time.Second, "Guard http server read timeout. Default is 5 seconds.")
s.AuthRecommendedOptions.AddFlags(fs)
s.AuthzRecommendedOptions.AddFlags(fs)
}
Expand Down Expand Up @@ -192,7 +194,7 @@ func (s Server) ListenAndServe() {

srv := &http.Server{
Addr: s.AuthRecommendedOptions.SecureServing.SecureAddr,
ReadTimeout: 5 * time.Second,
ReadTimeout: s.ReadTimeout,
WriteTimeout: s.WriteTimeout,
Handler: m,
TLSConfig: tlsConfig,
Expand Down