improved legacy support for module authorization policy
This commit is contained in:
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Infrastructure;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -11,23 +12,25 @@ namespace Oqtane.Controllers
|
||||
protected readonly ILogManager _logger;
|
||||
// querystring parameters for policy authorization and validation
|
||||
protected Dictionary<string, int> _authEntityId = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
protected int _entityId = -1; // deprecated
|
||||
protected int _entityId = -1; // legacy support
|
||||
|
||||
public ModuleControllerBase(ILogManager logger, IHttpContextAccessor accessor)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
// populate policy authorization dictionary
|
||||
int value;
|
||||
foreach (var param in accessor.HttpContext.Request.Query)
|
||||
{
|
||||
if (param.Key.StartsWith("auth") && param.Key.EndsWith("id") && int.TryParse(param.Value, out value))
|
||||
{
|
||||
_authEntityId.Add(param.Key.Substring(4, param.Key.Length - 6), int.Parse(param.Value));
|
||||
_authEntityId.Add(param.Key.Substring(4, param.Key.Length - 6), value);
|
||||
}
|
||||
}
|
||||
// entityid is deprecated
|
||||
if (accessor.HttpContext.Request.Query.ContainsKey("entityid"))
|
||||
// legacy support
|
||||
if (_authEntityId.ContainsKey(EntityNames.Module))
|
||||
{
|
||||
_entityId = int.Parse(accessor.HttpContext.Request.Query["entityid"]);
|
||||
_entityId = _authEntityId[EntityNames.Module];
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user