2 Commits

Author SHA1 Message Date
pcjones
37673f8a6c Fix wrong check for empty api key again -_- 2025-01-13 23:14:10 +01:00
pcjones
d2eaac7a6c Fix wrong check for empty API key 2025-01-13 23:09:24 +01:00
3 changed files with 3 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ namespace UmlautAdaptarr.Controllers
[HttpGet]
public async Task<IActionResult> Caps([FromRoute] string apiKey, [FromRoute] string domain, [FromQuery] string? apikey)
{
if (_options.ApiKey != null && !apiKey.Equals(apiKey))
if (!string.IsNullOrEmpty(apikey) && !apiKey.Equals(apiKey))
{
_logger.LogWarning("Invalid or missing API key for request.");
return Unauthorized("Unauthorized: Invalid or missing API key.");

View File

@@ -169,7 +169,7 @@ namespace UmlautAdaptarr.Controllers
internal bool AssureApiKey(string apiKey)
{
if (options.Value.ApiKey != null && !apiKey.Equals(options.Value.ApiKey))
if (!string.IsNullOrEmpty(options.Value.ApiKey) && !apiKey.Equals(options.Value.ApiKey))
{
logger.LogWarning("Invalid or missing API key for request.");
return false;

View File

@@ -130,7 +130,7 @@ namespace UmlautAdaptarr.Services
var url = _configuration["Kestrel:Endpoints:Http:Url"];
var port = new Uri(url).Port;
var apiKey = _options.ApiKey == null ? "_" : _options.ApiKey;
var apiKey = string.IsNullOrEmpty(_options.ApiKey) ? "_" : _options.ApiKey;
var modifiedUri = $"http://localhost:{port}/{apiKey}/{uri.Host}{uri.PathAndQuery}";
using var client = _clientFactory.CreateClient();