From 9a5a9cc40ccd0c5e0e974a5a455ea60fb1f6eb86 Mon Sep 17 00:00:00 2001 From: Michael Kochell <6913320+mickmister@users.noreply.github.com> Date: Tue, 15 Nov 2022 03:40:35 -0500 Subject: [PATCH 1/2] change oauth completetimeout to 5 minutes --- server/plugin/api.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/plugin/api.go b/server/plugin/api.go index 487644b39..8286056c3 100644 --- a/server/plugin/api.go +++ b/server/plugin/api.go @@ -27,7 +27,8 @@ const ( // TokenTTL is the OAuth token expiry duration in seconds TokenTTL = 10 * 60 - requestTimeout = 30 * time.Second + requestTimeout = 30 * time.Second + oauthCompleteTimeout = 5 * time.Minute ) type OAuthState struct { @@ -385,7 +386,10 @@ func (p *Plugin) completeConnectUserToGitHub(c *Context, w http.ResponseWriter, conf := p.getOAuthConfig(state.PrivateAllowed) - tok, err := conf.Exchange(c.Ctx, code) + ctx, cancel := context.WithTimeout(context.Background(), oauthCompleteTimeout) + defer cancel() + + tok, err := conf.Exchange(ctx, code) if err != nil { c.Log.WithError(err).Warnf("Failed to exchange oauth code into token") @@ -395,7 +399,7 @@ func (p *Plugin) completeConnectUserToGitHub(c *Context, w http.ResponseWriter, } githubClient := p.githubConnectToken(*tok) - gitUser, _, err := githubClient.Users.Get(c.Ctx, "") + gitUser, _, err := githubClient.Users.Get(ctx, "") if err != nil { c.Log.WithError(err).Warnf("Failed to get authenticated GitHub user") From f7f593786ba405df553204c0bb78808a3fdc7b8b Mon Sep 17 00:00:00 2001 From: Michael Kochell <6913320+mickmister@users.noreply.github.com> Date: Wed, 16 Nov 2022 15:04:40 -0500 Subject: [PATCH 2/2] change timeout to 2 minutes --- server/plugin/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/plugin/api.go b/server/plugin/api.go index 8286056c3..3ef3eda4f 100644 --- a/server/plugin/api.go +++ b/server/plugin/api.go @@ -28,7 +28,7 @@ const ( TokenTTL = 10 * 60 requestTimeout = 30 * time.Second - oauthCompleteTimeout = 5 * time.Minute + oauthCompleteTimeout = 2 * time.Minute ) type OAuthState struct {