Better duo status message handling (#3834)

This commit is contained in:
Jeff Mitchell 2018-01-23 14:18:48 -05:00 committed by GitHub
parent 85560b6295
commit feed3b9b95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -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
}