コード例 #1
0
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, OrgDivDataRequirement requirement)
        {
            _logger.LogDebug($"Attempting to access resource protected with the {requirement.RequirementName} handler.");

            DataIds ids       = _reader.GetDataIds(context.Resource);
            bool    canAccess = CheckData(context.User, requirement.RequiredGroups, ids);

            if (canAccess)
            {
                _logger.LogDebug($"Principal WAS ABLE access resource protected with the {requirement.RequirementName} handler.  Principal Summary: {context.User.ForLogging()}");
                context.Succeed(requirement);
            }
            else
            {
                _logger.LogDebug($"Principal IS UNABLE to access resource protected with the {requirement.RequirementName} handler.  Principal Summary: {context.User.ForLogging()}");
                context.Fail();
            }

            return(Task.CompletedTask);
        }