Skip to content

Commit 1c273f2

Browse files
committed
Adds callback mode that is direct to vault
1 parent f0ca12f commit 1c273f2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cli.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,26 @@ func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, erro
187187
}
188188
}
189189

190+
if callbackMode == "direct" {
191+
data := map[string]interface{}{
192+
"state": state,
193+
"client_nonce": clientNonce,
194+
}
195+
pollUrl := fmt.Sprintf("auth/%s/oidc/poll", mount)
196+
for {
197+
time.Sleep(time.Duration(interval) * time.Second)
198+
199+
secret, err := c.Logical().Write(pollUrl, data)
200+
if err == nil {
201+
return secret, nil
202+
}
203+
if !strings.HasSuffix(err.Error(), "authorization_pending") {
204+
return nil, err
205+
}
206+
// authorization is pending, try again
207+
}
208+
}
209+
190210
// Start local server
191211
go func() {
192212
err := http.Serve(listener, nil)

0 commit comments

Comments
 (0)