Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37673f8a6c | ||
|
|
d2eaac7a6c | ||
|
|
aa3765bcf2 |
@@ -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.");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"SETTINGS__ApiKey": "test123"
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"_launchUrl": "optionsTODO/example.com/api?t=movie&apikey=132&imdbid=123&limit=100",
|
||||
"dotnetRunMessages": true,
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace UmlautAdaptarr.Services
|
||||
var bytesRead = await clientStream.ReadAsync(buffer);
|
||||
var requestString = Encoding.ASCII.GetString(buffer, 0, bytesRead);
|
||||
|
||||
if (_options.ApiKey != null)
|
||||
if (!string.IsNullOrEmpty(_options.ApiKey))
|
||||
{
|
||||
var headers = ParseHeaders(buffer, bytesRead);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user