mirror of
https://github.com/bitwarden/server.git
synced 2025-02-26 03:31:34 +01:00
[PM-6577] Handle any exceptions in Duo HealthCheck (#3861)
* Handle any exceptions in health check to avoid returning a 500. * Added log message.
This commit is contained in:
parent
386ff744ef
commit
10457c67e3
@ -4,6 +4,7 @@ using Bit.Core.Context;
|
|||||||
using Bit.Core.Entities;
|
using Bit.Core.Entities;
|
||||||
using Bit.Core.Settings;
|
using Bit.Core.Settings;
|
||||||
using Bit.Core.Tokens;
|
using Bit.Core.Tokens;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Duo = DuoUniversal;
|
using Duo = DuoUniversal;
|
||||||
|
|
||||||
namespace Bit.Core.Auth.Identity;
|
namespace Bit.Core.Auth.Identity;
|
||||||
@ -25,6 +26,7 @@ public class TemporaryDuoWebV4SDKService : ITemporaryDuoWebV4SDKService
|
|||||||
private readonly ICurrentContext _currentContext;
|
private readonly ICurrentContext _currentContext;
|
||||||
private readonly GlobalSettings _globalSettings;
|
private readonly GlobalSettings _globalSettings;
|
||||||
private readonly IDataProtectorTokenFactory<DuoUserStateTokenable> _tokenDataFactory;
|
private readonly IDataProtectorTokenFactory<DuoUserStateTokenable> _tokenDataFactory;
|
||||||
|
private readonly ILogger<TemporaryDuoWebV4SDKService> _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for the DuoUniversalPromptService. Used to supplement v2 implementation of Duo with v4 SDK
|
/// Constructor for the DuoUniversalPromptService. Used to supplement v2 implementation of Duo with v4 SDK
|
||||||
@ -34,11 +36,13 @@ public class TemporaryDuoWebV4SDKService : ITemporaryDuoWebV4SDKService
|
|||||||
public TemporaryDuoWebV4SDKService(
|
public TemporaryDuoWebV4SDKService(
|
||||||
ICurrentContext currentContext,
|
ICurrentContext currentContext,
|
||||||
GlobalSettings globalSettings,
|
GlobalSettings globalSettings,
|
||||||
IDataProtectorTokenFactory<DuoUserStateTokenable> tokenDataFactory)
|
IDataProtectorTokenFactory<DuoUserStateTokenable> tokenDataFactory,
|
||||||
|
ILogger<TemporaryDuoWebV4SDKService> logger)
|
||||||
{
|
{
|
||||||
_currentContext = currentContext;
|
_currentContext = currentContext;
|
||||||
_globalSettings = globalSettings;
|
_globalSettings = globalSettings;
|
||||||
_tokenDataFactory = tokenDataFactory;
|
_tokenDataFactory = tokenDataFactory;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -129,8 +133,9 @@ public class TemporaryDuoWebV4SDKService : ITemporaryDuoWebV4SDKService
|
|||||||
(string)provider.MetaData["Host"],
|
(string)provider.MetaData["Host"],
|
||||||
redirectUri).Build();
|
redirectUri).Build();
|
||||||
|
|
||||||
if (!await client.DoHealthCheck())
|
if (!await client.DoHealthCheck(true))
|
||||||
{
|
{
|
||||||
|
_logger.LogError("Unable to connect to Duo. Health check failed.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return client;
|
return client;
|
||||||
|
Loading…
Reference in New Issue
Block a user