From feed3b9b95de04d8f3fad98e8419a7cc5ba6da6e Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 23 Jan 2018 14:18:48 -0500 Subject: [PATCH] Better duo status message handling (#3834) --- helper/mfa/duo/path_duo_access.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/helper/mfa/duo/path_duo_access.go b/helper/mfa/duo/path_duo_access.go index 2eb0b3278..4b577ef0a 100644 --- a/helper/mfa/duo/path_duo_access.go +++ b/helper/mfa/duo/path_duo_access.go @@ -69,11 +69,18 @@ func GetDuoAuthClient(ctx context.Context, req *logical.Request, config *DuoConf if err != nil { return nil, err } - if check == nil || check.StatResult.Message == nil || check.StatResult.Message_Detail == nil { + if check == nil { return nil, fmt.Errorf("Could not connect to Duo; got nil result back from API check call") } + var msg, detail string + if check.StatResult.Message != nil { + msg = *check.StatResult.Message + } + if check.StatResult.Message_Detail != nil { + detail = *check.StatResult.Message_Detail + } if check.StatResult.Stat != "OK" { - return nil, fmt.Errorf("Could not connect to Duo: %s (%s)", *check.StatResult.Message, *check.StatResult.Message_Detail) + return nil, fmt.Errorf("Could not connect to Duo: %s (%s)", msg, detail) } return duoAuthClient, nil }