Merge pull request #2579 from sbwalker/dev
Suppress unauthorized visitor logging as it is usually caused by clients that do not support cookies
This commit is contained in:
commit
cf2d9af664
|
@ -63,10 +63,14 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// suppress unauthorized visitor logging as it is usually caused by clients that do not support cookies
|
||||
if (entityName != EntityNames.Visitor)
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Settings {EntityName} {EntityId}", entityName, entityId);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
@ -84,9 +88,12 @@ namespace Oqtane.Controllers
|
|||
return setting;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entityName != EntityNames.Visitor)
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Setting {EntityName} {SettingId}", entityName, id);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +109,12 @@ namespace Oqtane.Controllers
|
|||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Setting Added {Setting}", setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (setting.EntityName != EntityNames.Visitor)
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Setting {Setting}", setting);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
setting = null;
|
||||
}
|
||||
return setting;
|
||||
|
@ -121,9 +131,12 @@ namespace Oqtane.Controllers
|
|||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Setting Updated {Setting}", setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (setting.EntityName != EntityNames.Visitor)
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Setting {Setting}", setting);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
setting = null;
|
||||
}
|
||||
return setting;
|
||||
|
@ -141,11 +154,14 @@ namespace Oqtane.Controllers
|
|||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Setting Deleted {Setting}", setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entityName != EntityNames.Visitor)
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Setting {Setting}", setting);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/clear
|
||||
[HttpDelete("clear")]
|
||||
|
@ -219,10 +235,12 @@ namespace Oqtane.Controllers
|
|||
authorized = User.IsInRole(RoleNames.Admin);
|
||||
if (!authorized)
|
||||
{
|
||||
// a visitor may have cookies disabled
|
||||
if (int.TryParse(Request.Cookies[_visitorCookie], out int visitorId))
|
||||
{
|
||||
authorized = (visitorId == entityId);
|
||||
}
|
||||
authorized = false;
|
||||
}
|
||||
break;
|
||||
default: // custom entity
|
||||
|
|
|
@ -20,7 +20,6 @@ using Oqtane.Enums;
|
|||
using Oqtane.Security;
|
||||
using Oqtane.Extensions;
|
||||
using Oqtane.Themes;
|
||||
using Oqtane.UI;
|
||||
|
||||
namespace Oqtane.Pages
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Oqtane.Shared
|
|||
public Alias Alias { get; set; }
|
||||
public string AntiForgeryToken { get; set; } // passed from server for use in service calls on client
|
||||
public string AuthorizationToken { get; set; } // passed from server for use in service calls on client
|
||||
public string RemoteIPAddress { get; set; } // passed from server as cannot be reliable retrieved on client
|
||||
public string RemoteIPAddress { get; set; } // passed from server as cannot be reliably retrieved on client
|
||||
|
||||
|
||||
private dynamic _properties;
|
||||
|
|
Loading…
Reference in New Issue
Block a user