1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-11 01:01:36 +01:00

HaveIBeenPwned API key not set.

This commit is contained in:
Kyle Spearrin 2019-07-27 12:29:20 -04:00
parent 8d09a7ad13
commit 6640e64876

View File

@ -9,6 +9,7 @@ using Bit.Core;
using System.Net; using System.Net;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using System.Linq; using System.Linq;
using Bit.Core.Utilities;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -49,11 +50,12 @@ namespace Bit.Api.Controllers
private async Task<IActionResult> SendAsync(string username, bool retry) private async Task<IActionResult> SendAsync(string username, bool retry)
{ {
var request = new HttpRequestMessage(HttpMethod.Get, string.Format(HibpBreachApi, username)); if(!CoreHelpers.SettingHasValue(_globalSettings.HibpApiKey))
if(!string.IsNullOrWhiteSpace(_globalSettings.HibpApiKey))
{ {
request.Headers.Add("hibp-api-key", _globalSettings.HibpApiKey); throw new BadRequestException("HaveIBeenPwned API key not set.");
} }
var request = new HttpRequestMessage(HttpMethod.Get, string.Format(HibpBreachApi, username));
request.Headers.Add("hibp-api-key", _globalSettings.HibpApiKey);
request.Headers.Add("hibp-client-id", GetClientId()); request.Headers.Add("hibp-client-id", GetClientId());
request.Headers.Add("User-Agent", _userAgent); request.Headers.Add("User-Agent", _userAgent);
var response = await _httpClient.SendAsync(request); var response = await _httpClient.SendAsync(request);