Skip to content

Commit

Permalink
Merge pull request #2273 from Atralupus/feat/acs-logging
Browse files Browse the repository at this point in the history
Add acs access denied debug log
  • Loading branch information
Atralupus authored Oct 19, 2023
2 parents dbdbd3c + 9c06624 commit e44aa4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using StackExchange.Redis;
using Libplanet.Crypto;
using Nekoyume.Blockchain;
using Serilog;

namespace NineChronicles.Headless.Services
{
Expand All @@ -16,7 +17,13 @@ public RedisAccessControlService(string storageUri)

public bool IsAccessDenied(Address address)
{
return _db.KeyExists(address.ToString());
var result = _db.KeyExists(address.ToString());
if (result)
{
Log.Debug($"{address} is access denied");
}

return result;
}
}
}
12 changes: 10 additions & 2 deletions NineChronicles.Headless/Services/SQLiteAccessControlService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Data.Sqlite;
using Libplanet.Crypto;
using Nekoyume.Blockchain;
using Serilog;

namespace NineChronicles.Headless.Services
{
Expand Down Expand Up @@ -33,9 +34,16 @@ public bool IsAccessDenied(Address address)
command.CommandText = CheckAccessSql;
command.Parameters.AddWithValue("@Address", address.ToString());

var result = command.ExecuteScalar();
var queryResult = command.ExecuteScalar();

return result is not null && (long)result == 1;
var result = queryResult is not null && (long)queryResult == 1;

if (result)
{
Log.Debug($"{address} is access denied");
}

return result;
}
}
}

0 comments on commit e44aa4c

Please sign in to comment.