Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Psichorex committed Jan 30, 2024
1 parent edc7f6b commit ca914d8
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
namespace Lombiq.HelpfulExtensions.Extensions.Security.Services;

[RequireFeatures(FeatureIds.Security)]
public class StrictSecurityPermissionAuthorizationHandler(IContentDefinitionManager contentDefinitionManager) : AuthorizationHandler<PermissionRequirement>
public class StrictSecurityPermissionAuthorizationHandler : AuthorizationHandler<PermissionRequirement>
{
private readonly IContentDefinitionManager _contentDefinitionManager;

public StrictSecurityPermissionAuthorizationHandler(IContentDefinitionManager contentDefinitionManager) =>
_contentDefinitionManager = contentDefinitionManager;

private static readonly Dictionary<string, IList<string>> _permissionTemplates = ContentTypePermissionsHelper
.PermissionTemplates
.ToDictionary(
Expand All @@ -26,7 +31,7 @@ protected override async Task HandleRequirementAsync(AuthorizationHandlerContext
{
if ((context.Resource as IContent)?.ContentItem is not { } contentItem ||
!_permissionTemplates.TryGetValue(requirement.Permission.Name, out var claims) ||
await contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType) is not { } definition ||
await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType) is not { } definition ||
definition.GetSettings<StrictSecuritySettings>()?.Enabled != true)
{
return;
Expand Down

0 comments on commit ca914d8

Please sign in to comment.