Skip to content

Commit

Permalink
Add timeout to OIDC callback listener (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianferguson authored Feb 12, 2020
1 parent daffb43 commit 026b6c9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"regexp"
"runtime"
"strings"
"time"

"github.com/hashicorp/vault/api"
)
Expand Down Expand Up @@ -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")
}
}

Expand Down

0 comments on commit 026b6c9

Please sign in to comment.