protected override async Task HandleRequirementAsync(
            AuthorizationHandlerContext context,
            AssignPrereleaseContactsToSpecificReleaseRequirement requirement,
            Release release)
        {
            if (SecurityUtils.HasClaim(context.User, UpdateAllReleases))
            {
                context.Succeed(requirement);
                return;
            }

            var publicationRoles =
                await _userPublicationRoleRepository.GetAllRolesByUser(context.User.GetUserId(), release.PublicationId);

            if (ContainPublicationOwnerRole(publicationRoles))
            {
                context.Succeed(requirement);
                return;
            }

            var releaseRoles = await _userReleaseRoleRepository.GetAllRolesByUser(context.User.GetUserId(), release.Id);

            if (ContainsEditorOrApproverRole(releaseRoles))
            {
                context.Succeed(requirement);
            }
        }
        protected override async Task HandleRequirementAsync(
            AuthorizationHandlerContext context,
            UpdateSpecificReleaseRequirement requirement,
            Release release)
        {
            var statuses = await _releasePublishingStatusRepository.GetAllByOverallStage(
                release.Id,
                ReleasePublishingStatusOverallStage.Started,
                ReleasePublishingStatusOverallStage.Complete
                );

            if (statuses.Any() || release.Published != null)
            {
                return;
            }

            if (SecurityUtils.HasClaim(context.User, SecurityClaimTypes.UpdateAllReleases))
            {
                context.Succeed(requirement);
                return;
            }

            var publicationRoles =
                await _publicationRoleRepository.GetAllRolesByUser(context.User.GetUserId(), release.PublicationId);

            var releaseRoles = await _releaseRoleRepository.GetAllRolesByUser(context.User.GetUserId(), release.Id);

            if (release.ApprovalStatus == ReleaseApprovalStatus.Approved
                ? ContainsApproverRole(releaseRoles)
                : ContainPublicationOwnerRole(publicationRoles) || ContainsEditorOrApproverRole(releaseRoles))
            {
                context.Succeed(requirement);
            }
        }
        private async Task HandleHigherLevelReview(
            AuthorizationHandlerContext context,
            TRequirement requirement,
            Release release)
        {
            if (SecurityUtils.HasClaim(context.User, SecurityClaimTypes.SubmitAllReleasesToHigherReview))
            {
                context.Succeed(requirement);
                return;
            }

            var publicationRoles =
                await _userPublicationRoleRepository.GetAllRolesByUser(context.User.GetUserId(), release.PublicationId);

            var releaseRoles = await _userReleaseRoleRepository.GetAllRolesByUser(context.User.GetUserId(), release.Id);

            if (release.ApprovalStatus == ReleaseApprovalStatus.Approved
                ? ContainsApproverRole(releaseRoles)
                : ContainPublicationOwnerRole(publicationRoles) || ContainsEditorOrApproverRole(releaseRoles))
            {
                context.Succeed(requirement);
            }
        }
            protected override async Task HandleRequirementAsync(
                AuthorizationHandlerContext context,
                ViewReleaseRequirement requirement,
                Release release)
            {
                var publicationRoles =
                    await _userPublicationRoleRepository.GetAllRolesByUser(context.User.GetUserId(),
                                                                           release.PublicationId);

                if (ContainPublicationOwnerRole(publicationRoles))
                {
                    context.Succeed(requirement);
                }
            }
        protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context,
                                                             TRequirement requirement,
                                                             Publication publication)
        {
            var publicationRoles = await _publicationRoleRepository.GetAllRolesByUser(context.User.GetUserId(), publication.Id);

            if (publicationRoles.Any())
            {
                if (_roleTest == null || _roleTest.Invoke(new PublicationRolesAuthorizationContext(publication, publicationRoles)))
                {
                    context.Succeed(requirement);
                }
            }
        }
示例#6
0
        protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context,
                                                             UpdatePublicationRequirement requirement,
                                                             Publication publication)
        {
            if (SecurityUtils.HasClaim(context.User, UpdateAllPublications))
            {
                context.Succeed(requirement);
                return;
            }

            var publicationRoles = await _userPublicationRoleRepository.GetAllRolesByUser(context.User.GetUserId(), publication.Id);

            if (ContainPublicationOwnerRole(publicationRoles))
            {
                context.Succeed(requirement);
            }
        }
        protected override async Task HandleRequirementAsync(
            AuthorizationHandlerContext authContext,
            ViewReleaseStatusHistoryRequirement requirement,
            Release release)
        {
            if (SecurityUtils.HasClaim(authContext.User, SecurityClaimTypes.AccessAllReleases))
            {
                authContext.Succeed(requirement);
                return;
            }

            var publicationRoles = await _publicationRoleRepository
                                   .GetAllRolesByUser(authContext.User.GetUserId(), release.PublicationId);

            var releaseRoles = await _releaseRoleRepository
                               .GetAllRolesByUser(authContext.User.GetUserId(), release.Id);

            if (ContainPublicationOwnerRole(publicationRoles) || ContainsUnrestrictedViewerRole(releaseRoles))
            {
                authContext.Succeed(requirement);
            }
        }
示例#8
0
        protected override async Task HandleRequirementAsync(
            AuthorizationHandlerContext context,
            DeleteSpecificReleaseRequirement requirement,
            Release release)
        {
            if (!release.Amendment || release.ApprovalStatus == Approved)
            {
                return;
            }

            if (SecurityUtils.HasClaim(context.User, DeleteAllReleaseAmendments))
            {
                context.Succeed(requirement);
                return;
            }

            var publicationRoles = await _userPublicationRoleRepository.GetAllRolesByUser(context.User.GetUserId(), release.PublicationId);

            if (ContainPublicationOwnerRole(publicationRoles))
            {
                context.Succeed(requirement);
            }
        }
示例#9
0
        protected override async Task HandleRequirementAsync(
            AuthorizationHandlerContext context,
            MakeAmendmentOfSpecificReleaseRequirement requirement,
            Release release)
        {
            if (!release.Live || !IsLatestVersionOfRelease(_contentDbContext, release))
            {
                return;
            }

            if (SecurityUtils.HasClaim(context.User, MakeAmendmentsOfAllReleases))
            {
                context.Succeed(requirement);
                return;
            }

            var publicationRoles =
                await _userPublicationRoleRepository.GetAllRolesByUser(context.User.GetUserId(), release.PublicationId);

            if (ContainPublicationOwnerRole(publicationRoles))
            {
                context.Succeed(requirement);
            }
        }