(connCtx context.Context, remoteDisplayName string, password *string, debugInfo *ConnectionDebugInfo)
| 383 | } |
| 384 | |
| 385 | func createPasswordCallbackPrompt(connCtx context.Context, remoteDisplayName string, password *string, debugInfo *ConnectionDebugInfo) func() (secret string, err error) { |
| 386 | return func() (secret string, outErr error) { |
| 387 | defer func() { |
| 388 | panicErr := panichandler.PanicHandler("sshclient:password-callback", recover()) |
| 389 | if panicErr != nil { |
| 390 | outErr = panicErr |
| 391 | } |
| 392 | }() |
| 393 | blocklogger.Infof(connCtx, "[conndebug] Password Authentication requested from connection %s...\n", remoteDisplayName) |
| 394 | |
| 395 | if password != nil { |
| 396 | blocklogger.Infof(connCtx, "[conndebug] using password from secret store, sending to ssh\n") |
| 397 | return *password, nil |
| 398 | } |
| 399 | |
| 400 | ctx, cancelFn := context.WithTimeout(connCtx, 60*time.Second) |
| 401 | defer cancelFn() |
| 402 | queryText := fmt.Sprintf( |
| 403 | "Password Authentication requested from connection \n"+ |
| 404 | "%s\n\n"+ |
| 405 | "Password:", remoteDisplayName) |
| 406 | request := &userinput.UserInputRequest{ |
| 407 | ResponseType: "text", |
| 408 | QueryText: queryText, |
| 409 | Markdown: true, |
| 410 | Title: "Password Authentication", |
| 411 | } |
| 412 | response, err := userinput.GetUserInput(ctx, request) |
| 413 | if err != nil { |
| 414 | blocklogger.Infof(connCtx, "[conndebug] ERROR Password Authentication failed: %v\n", SimpleMessageFromPossibleConnectionError(err)) |
| 415 | return "", ConnectionError{ConnectionDebugInfo: debugInfo, Err: err} |
| 416 | } |
| 417 | blocklogger.Infof(connCtx, "[conndebug] got password from user, sending to ssh\n") |
| 418 | return response.Text, nil |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | func createInteractiveKbdInteractiveChallenge(connCtx context.Context, remoteName string, debugInfo *ConnectionDebugInfo) func(name, instruction string, questions []string, echos []bool) (answers []string, err error) { |
| 423 | return func(name, instruction string, questions []string, echos []bool) (answers []string, outErr error) { |
no test coverage detected