always check authentication

This commit is contained in:
Pilzinsel64
2025-06-04 09:21:58 +02:00
parent a02332745b
commit 8aa562afee

View File

@@ -481,10 +481,9 @@ public class ApiServer : IApiServer
// Check authentication // Check authentication
Log.Debug("Check authentication"); Log.Debug("Check authentication");
var isAuthenticated = false; var isAuthenticated = false;
if (!string.IsNullOrWhiteSpace(authKey) && DecodeAuthKey(authKey) is string authKeyDecoded) if (string.IsNullOrWhiteSpace(authKey) || DecodeAuthKey(authKey) is not string authKeyDecoded)
isAuthenticated = CheckAuthentication(authKeyDecoded, handler.Handler, context);
else
authKeyDecoded = null!; authKeyDecoded = null!;
isAuthenticated = CheckAuthentication(authKeyDecoded, handler.Handler, context);
if (handler.Attribute.RequiesAuth && !isAuthenticated) if (handler.Attribute.RequiesAuth && !isAuthenticated)
return new(ApiResult.Unauthorized(), null); return new(ApiResult.Unauthorized(), null);