Skip to content

Commit

Permalink
Add timeout (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbilski committed May 23, 2023
1 parent 37948f7 commit 3f9ea71
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ The available flags are:
-s, --silent silent mode
--subject-token string third party token
--subject-token-type string third party token type
--timeout duration http client timeout (default 1m0s)
--tls-cert string path to tls cert pem file
--tls-key string path to tls key pem file
--tls-root-ca string path to tls root ca pem file
Expand Down
3 changes: 2 additions & 1 deletion cmd/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func NewOAuth2Cmd() (cmd *OAuth2Cmd) {
cmd.PersistentFlags().StringVar(&cconfig.TLSCert, "tls-cert", "", "path to tls cert pem file")
cmd.PersistentFlags().StringVar(&cconfig.TLSKey, "tls-key", "", "path to tls key pem file")
cmd.PersistentFlags().StringVar(&cconfig.TLSRootCA, "tls-root-ca", "", "path to tls root ca pem file")
cmd.PersistentFlags().DurationVar(&cconfig.Timeout, "timeout", time.Minute, "http client timeout")
cmd.PersistentFlags().BoolVar(&cconfig.Insecure, "insecure", false, "allow insecure connections")
cmd.PersistentFlags().BoolVarP(&silent, "silent", "s", false, "silent mode")
cmd.PersistentFlags().BoolVar(&cconfig.DPoP, "dpop", false, "use DPoP")
Expand Down Expand Up @@ -112,7 +113,7 @@ func (c *OAuth2Cmd) Run(cconfig *oauth2.ClientConfig) func(cmd *cobra.Command, a
},
}

hc := &http.Client{Timeout: 10 * time.Second, Transport: tr}
hc := &http.Client{Timeout: cconfig.Timeout, Transport: tr}

if cconfig.TLSCert != "" && cconfig.TLSKey != "" {
if cert, err = oauth2.ReadKeyPair(cconfig.TLSCert, cconfig.TLSKey, hc); err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/oauth2/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type ClientConfig struct {
TLSCert string
TLSKey string
TLSRootCA string
Timeout time.Duration
DPoP bool
Claims string
}
Expand Down

0 comments on commit 3f9ea71

Please sign in to comment.