3 Commits
v0.7 ... 0.7.2

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
pcjones
aa3765bcf2 Fix Proxy not working if no api key was set 2025-01-13 23:01:14 +01:00
4 changed files with 5 additions and 6 deletions

View File

@@ -18,7 +18,7 @@ namespace UmlautAdaptarr.Controllers
[HttpGet] [HttpGet]
public async Task<IActionResult> Caps([FromRoute] string apiKey, [FromRoute] string domain, [FromQuery] string? apikey) 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."); _logger.LogWarning("Invalid or missing API key for request.");
return Unauthorized("Unauthorized: Invalid or missing API key."); return Unauthorized("Unauthorized: Invalid or missing API key.");

View File

@@ -169,7 +169,7 @@ namespace UmlautAdaptarr.Controllers
internal bool AssureApiKey(string apiKey) 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."); logger.LogWarning("Invalid or missing API key for request.");
return false; return false;

View File

@@ -3,8 +3,7 @@
"http": { "http": {
"commandName": "Project", "commandName": "Project",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development"
"SETTINGS__ApiKey": "test123"
}, },
"_launchUrl": "optionsTODO/example.com/api?t=movie&apikey=132&imdbid=123&limit=100", "_launchUrl": "optionsTODO/example.com/api?t=movie&apikey=132&imdbid=123&limit=100",
"dotnetRunMessages": true, "dotnetRunMessages": true,

View File

@@ -42,7 +42,7 @@ namespace UmlautAdaptarr.Services
var bytesRead = await clientStream.ReadAsync(buffer); var bytesRead = await clientStream.ReadAsync(buffer);
var requestString = Encoding.ASCII.GetString(buffer, 0, bytesRead); var requestString = Encoding.ASCII.GetString(buffer, 0, bytesRead);
if (_options.ApiKey != null) if (!string.IsNullOrEmpty(_options.ApiKey))
{ {
var headers = ParseHeaders(buffer, bytesRead); var headers = ParseHeaders(buffer, bytesRead);
@@ -130,7 +130,7 @@ namespace UmlautAdaptarr.Services
var url = _configuration["Kestrel:Endpoints:Http:Url"]; var url = _configuration["Kestrel:Endpoints:Http:Url"];
var port = new Uri(url).Port; 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}"; var modifiedUri = $"http://localhost:{port}/{apiKey}/{uri.Host}{uri.PathAndQuery}";
using var client = _clientFactory.CreateClient(); using var client = _clientFactory.CreateClient();