From 026b6c94c5bf5f507cdb3c5d6cd5da5f85149277 Mon Sep 17 00:00:00 2001 From: Ian Ferguson Date: Wed, 12 Feb 2020 00:53:37 -0500 Subject: [PATCH] Add timeout to OIDC callback listener (#97) --- cli.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli.go b/cli.go index 955d2120..06b20fd5 100644 --- a/cli.go +++ b/cli.go @@ -12,6 +12,7 @@ import ( "regexp" "runtime" "strings" + "time" "github.com/hashicorp/vault/api" ) @@ -120,12 +121,14 @@ func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, erro } }() - // Wait for either the callback to finish or SIGINT to be received + // Wait for either the callback to finish, SIGINT to be received or up to 2 minutes select { case s := <-doneCh: return s.secret, s.err case <-sigintCh: return nil, errors.New("Interrupted") + case <-time.After(2 * time.Minute): + return nil, errors.New("Timed out waiting for response from provider") } }