/// <summary>
 /// Filters the with public access.
 /// </summary>
 /// <param name="entityIds">The entity ids.</param>
 /// <param name="memberId">The member id.</param>
 /// <param name="publicAccessService">The public access service.</param>
 /// <returns></returns>
 public static IEnumerable<HiveId> FilterWithPublicAccess(this IEnumerable<HiveId> entityIds,
     HiveId memberId ,
     IPublicAccessService publicAccessService)
 {
     return memberId.IsNullValueOrEmpty()
         ? entityIds.Where(id => !publicAccessService.IsProtected(id))
         : entityIds.Where(id => publicAccessService.GetPublicAccessStatus(memberId, id).CanAccess);
 }
示例#2
0
        public SecurityService(IMembershipService<User> usersMembershipService, IMembershipService<Member> membersMembershipService,
            IPermissionsService permissionsService, IPublicAccessService publicAccessService)
        {
            Mandate.That<NullReferenceException>(usersMembershipService != null);
            Mandate.That<NullReferenceException>(membersMembershipService != null);
            Mandate.That<NullReferenceException>(permissionsService != null);
            Mandate.That<NullReferenceException>(publicAccessService != null);

            Users = usersMembershipService;
            Members = membersMembershipService;
            Permissions = permissionsService;
            PublicAccess = publicAccessService;
        }
        public async Task GivenMemberLoggedIn_WhenMemberHasRoles_AndContentDoesNotExist_ThenAccessAcceptedResult(
            IMemberManager memberManager,
            IPublicAccessService publicAccessService,
            IContentService contentService)
        {
            PublicAccessChecker sut = CreateSut(memberManager, publicAccessService, contentService, out HttpContext httpContext);

            httpContext.User = GetLoggedInUser();
            MockGetUserAsync(memberManager, new MemberIdentityUser {
                IsApproved = true
            });
            MockGetRolesAsync(memberManager);
            Mock.Get(contentService).Setup(x => x.GetById(123)).Returns((IContent)null);

            var result = await sut.HasMemberAccessToContentAsync(123);

            Assert.AreEqual(PublicAccessStatus.AccessAccepted, result);
        }
    public static bool HasAccess(this IPublicAccessService publicAccessService, int documentId, IContentService contentService, string username, IEnumerable <string> currentMemberRoles)
    {
        IContent?content = contentService.GetById(documentId);

        if (content == null)
        {
            return(true);
        }

        PublicAccessEntry?entry = publicAccessService.GetEntryForContent(content);

        if (entry == null)
        {
            return(true);
        }

        return(HasAccess(entry, username, currentMemberRoles));
    }
        public static bool HasAccess(this IPublicAccessService publicAccessService, int documentId, IContentService contentService, IEnumerable <string> currentMemberRoles)
        {
            var content = contentService.GetById(documentId);

            if (content == null)
            {
                return(true);
            }

            var entry = publicAccessService.GetEntryForContent(content);

            if (entry == null)
            {
                return(true);
            }

            return(entry.Rules.Any(x => x.RuleType == Constants.Conventions.PublicAccess.MemberRoleRuleType &&
                                   currentMemberRoles.Contains(x.RuleValue)));
        }
示例#6
0
 public ContentTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IEntityService entityService,
     IBackOfficeSecurityAccessor backofficeSecurityAccessor,
     ILogger <ContentTreeController> logger,
     ActionCollection actionCollection,
     IUserService userService,
     IDataTypeService dataTypeService,
     UmbracoTreeSearcher treeSearcher,
     ActionCollection actions,
     IContentService contentService,
     IPublicAccessService publicAccessService,
     ILocalizationService localizationService,
     IEventAggregator eventAggregator,
     IEmailSender emailSender,
     AppCaches appCaches)
     : base(
         localizedTextService,
         umbracoApiControllerTypeCollection,
         menuItemCollectionFactory,
         entityService,
         backofficeSecurityAccessor,
         logger,
         actionCollection,
         userService,
         dataTypeService,
         eventAggregator,
         appCaches)
 {
     _treeSearcher = treeSearcher;
     _actions      = actions;
     _menuItemCollectionFactory  = menuItemCollectionFactory;
     _backofficeSecurityAccessor = backofficeSecurityAccessor;
     _contentService             = contentService;
     _entityService       = entityService;
     _publicAccessService = publicAccessService;
     _userService         = userService;
     _localizationService = localizationService;
     _emailSender         = emailSender;
     _appCaches           = appCaches;
 }
示例#7
0
        public void Setup()
        {
            _nhibernateTestSetup = new NhibernateTestSetupHelper();

            var storageProvider = new IoHiveTestSetupHelper(_nhibernateTestSetup.FakeFrameworkContext);

            Hive = new HiveManager(
                new[]
            {
                new ProviderMappingGroup(
                    "test",
                    new WildcardUriMatch("content://"),
                    _nhibernateTestSetup.ReadonlyProviderSetup,
                    _nhibernateTestSetup.ProviderSetup,
                    _nhibernateTestSetup.FakeFrameworkContext),
                storageProvider.CreateGroup("uploader", "storage://file-uploader"),
            },
                _nhibernateTestSetup.FakeFrameworkContext);

            var appContext = new FakeRebelApplicationContext(Hive, false);

            var resolverContext   = new MockedMapResolverContext(_nhibernateTestSetup.FakeFrameworkContext, Hive, new MockedPropertyEditorFactory(appContext), new MockedParameterEditorFactory());
            var webmModelMapper   = new CmsModelMapper(resolverContext);
            var renderModelMapper = new RenderTypesModelMapper(resolverContext);

            _nhibernateTestSetup.FakeFrameworkContext.SetTypeMappers(new FakeTypeMapperCollection(new AbstractMappingEngine[] { webmModelMapper, renderModelMapper, new FrameworkModelMapper(_nhibernateTestSetup.FakeFrameworkContext) }));

            var membersMembershipProvider = new MembersMembershipProvider {
                AppContext = appContext
            };

            membersMembershipProvider.Initialize("MembersMembershipProvider", new NameValueCollection());
            MembershipService = new MembershipService <Member, MemberProfile>(appContext.FrameworkContext, Hive,
                                                                              "security://member-profiles", "security://member-groups", Framework.Security.Model.FixedHiveIds.MemberProfileVirtualRoot,
                                                                              membersMembershipProvider, Enumerable.Empty <MembershipProviderElement>());

            PublicAccessService = new PublicAccessService(Hive, MembershipService, appContext.FrameworkContext);

            var serializer = new ServiceStackSerialiser();

            SerializationService = new SerializationService(serializer);
        }
示例#8
0
 public MemberManager(
     IIpResolver ipResolver,
     IMemberUserStore store,
     IOptions <IdentityOptions> optionsAccessor,
     IPasswordHasher <MemberIdentityUser> passwordHasher,
     IEnumerable <IUserValidator <MemberIdentityUser> > userValidators,
     IEnumerable <IPasswordValidator <MemberIdentityUser> > passwordValidators,
     IdentityErrorDescriber errors,
     IServiceProvider services,
     ILogger <UserManager <MemberIdentityUser> > logger,
     IOptionsSnapshot <MemberPasswordConfigurationSettings> passwordConfiguration,
     IPublicAccessService publicAccessService,
     IHttpContextAccessor httpContextAccessor)
     : base(ipResolver, store, optionsAccessor, passwordHasher, userValidators, passwordValidators, errors,
            services, logger, passwordConfiguration)
 {
     _store = store;
     _publicAccessService = publicAccessService;
     _httpContextAccessor = httpContextAccessor;
 }
        public async Task GivenMemberLoggedIn_WhenMemberHasRoles_AndRoleRuleMatches_ThenAccessAcceptedResult(
            IMemberManager memberManager,
            IPublicAccessService publicAccessService,
            IContentService contentService,
            IContent content)
        {
            PublicAccessChecker sut = CreateSut(memberManager, publicAccessService, contentService, out HttpContext httpContext);

            httpContext.User = GetLoggedInUser();
            MockGetUserAsync(memberManager, new MemberIdentityUser {
                UserName = "******", IsApproved = true
            });
            MockGetRolesAsync(memberManager);
            Mock.Get(contentService).Setup(x => x.GetById(123)).Returns(content);
            Mock.Get(publicAccessService).Setup(x => x.GetEntryForContent(content)).Returns(GetPublicAccessEntry(string.Empty, "role1"));

            var result = await sut.HasMemberAccessToContentAsync(123);

            Assert.AreEqual(PublicAccessStatus.AccessAccepted, result);
        }
示例#10
0
        public void Setup()
        {
            _nhibernateTestSetup = new NhibernateTestSetupHelper();

            var storageProvider = new IoHiveTestSetupHelper(_nhibernateTestSetup.FakeFrameworkContext);

            Hive = new HiveManager(
                    new[]
                        {
                            new ProviderMappingGroup(
                                "test",
                                new WildcardUriMatch("content://"),
                                _nhibernateTestSetup.ReadonlyProviderSetup,
                                _nhibernateTestSetup.ProviderSetup,
                                _nhibernateTestSetup.FakeFrameworkContext),
                            storageProvider.CreateGroup("uploader", "storage://file-uploader"),
                        },
                    _nhibernateTestSetup.FakeFrameworkContext);

            var appContext = new FakeUmbracoApplicationContext(Hive, false);

            var resolverContext = new MockedMapResolverContext(_nhibernateTestSetup.FakeFrameworkContext, Hive, new MockedPropertyEditorFactory(appContext), new MockedParameterEditorFactory());
            var webmModelMapper = new CmsModelMapper(resolverContext);
            var renderModelMapper = new RenderTypesModelMapper(resolverContext);

            _nhibernateTestSetup.FakeFrameworkContext.SetTypeMappers(new FakeTypeMapperCollection(new AbstractMappingEngine[] { webmModelMapper, renderModelMapper, new FrameworkModelMapper(_nhibernateTestSetup.FakeFrameworkContext) }));

            var membersMembershipProvider = new MembersMembershipProvider { AppContext = appContext };
            membersMembershipProvider.Initialize("MembersMembershipProvider", new NameValueCollection());
            MembershipService = new MembershipService<Member, MemberProfile>(appContext.FrameworkContext, Hive,
                "security://member-profiles", "security://member-groups", Framework.Security.Model.FixedHiveIds.MemberProfileVirtualRoot,
                membersMembershipProvider, Enumerable.Empty<MembershipProviderElement>());

            PublicAccessService = new PublicAccessService(Hive, MembershipService, appContext.FrameworkContext);

            var serializer = new ServiceStackSerialiser();
            SerializationService = new SerializationService(serializer);
        }
        public void TestSetup()
        {
            this.Setup = new NhibernateTestSetupHelper();
            this._singleProvider = new ProviderMappingGroup("default", new WildcardUriMatch(new Uri("content://")), this.Setup.ReadonlyProviderSetup, this.Setup.ProviderSetup, this.Setup.FakeFrameworkContext);
            this.HiveManager = new HiveManager(this._singleProvider, this._singleProvider.FrameworkContext);

            this.AppContext = new FakeRebelApplicationContext(this.HiveManager, false);

            this._resolverContext = new MockedMapResolverContext(this.HiveManager.FrameworkContext, this.HiveManager, new MockedPropertyEditorFactory(this.AppContext), new MockedParameterEditorFactory());

            //mappers
            var cmsModelMapper = new CmsModelMapper(this._resolverContext);
            var persistenceToRenderModelMapper = new RenderTypesModelMapper(this._resolverContext);
            
            this.Setup.FakeFrameworkContext.SetTypeMappers(new FakeTypeMapperCollection(new AbstractMappingEngine[] { cmsModelMapper, persistenceToRenderModelMapper }));

            var membersMembershipProvider = new MembersMembershipProvider { AppContext = AppContext };
            MembershipService = new MembershipService<Member, MemberProfile>(AppContext.FrameworkContext, HiveManager,
                "security://member-profiles", "security://member-groups", Framework.Security.Model.FixedHiveIds.MemberProfileVirtualRoot,
                membersMembershipProvider, Enumerable.Empty<MembershipProviderElement>());

            PublicAccessService = new PublicAccessService(HiveManager, MembershipService, AppContext.FrameworkContext);
        }
 public ArticleIndexCreator(IProfilingLogger profilingLogger, ILocalizationService localizationService, IPublicAccessService publicAccessService)
 {
     _profilingLogger     = profilingLogger;
     _localizationService = localizationService;
     _publicAccessService = publicAccessService;
 }
 public ValueSetHelper(IPublicAccessService publicAccessService)
 {
     _publicAccessService = publicAccessService;
 }
 private void PublicAccessService_Saved(IPublicAccessService sender, Core.Events.SaveEventArgs <PublicAccessEntry> args)
 => PublicAccessServiceSaved(args, _contentService);
示例#15
0
 public TagsController(IPublicAccessService publicAccessService)
 {
     _publicAccessService = publicAccessService;
 }
示例#16
0
 public DynamicContentList(HiveId sourceId, IHiveManager hiveManager, IMembershipService <Member> membershipService, IPublicAccessService publicAccessService,
                           object defaultValueIfNull, IEnumerable <HiveId> containedIds)
     : this(sourceId, hiveManager, membershipService, publicAccessService, defaultValueIfNull, containedIds,
            hiveManager.Query <TypedEntity, IContentStore>().OfRevisionType(FixedStatusTypes.Published).InIds(containedIds.ToArray()))
 {
 }
        public static dynamic Bend(this Content content, IHiveManager hiveManager, IMembershipService <Member> membershipService,
                                   IPublicAccessService publicAccessService, IEnumerable <Assembly> dynamicExtensionAssemblies = null)
        {
            if (content == null)
            {
                return(null);
            }

            var     bendy        = new BendyObject(content);
            dynamic dynamicBendy = bendy;

            //get all fields that have a value
            var attributesWithValue = content.Attributes.Where(typedAttribute => typedAttribute.Values.Any()).ToArray();

            foreach (var attrib in attributesWithValue)
            {
                //if the default value doesn't exist, then add to sub bendy... normally this occurs if the
                // property editor is saving custom values
                var defaultval = attrib.Values.GetDefaultValue();
                if (attrib.Values.Count > 1 || defaultval == null)
                {
                    //03/05/12 (SD). we only need to create one sub bendy, then assign it to each property alias
                    // this used to create 2 of them not sure why as this will just have more overhead.
                    // This also used to create a new bendy object, then iterate over each of the attrib.Values and
                    //manually assign each value using AddToBendy. This has changed so that we can better support
                    //multi-value properties and because the BendyObject ctor now has support to check for IDictionary
                    //which automatically adds each dictionary key/value as a property.
                    var subBendy = new BendyObject(attrib.Values);
                    AddToBendy(bendy, attrib.AttributeDefinition.Alias, subBendy);

                    subBendy["__OriginalItem"] = attrib;
                    subBendy.AddLazy("__Parent", () => bendy);
                    subBendy["__ParentKey"] = attrib.AttributeDefinition.Alias;

                    BendyObjectExtensionsHelper.ApplyDynamicFieldExtensions(content,
                                                                            attrib.AttributeDefinition.AttributeType.RenderTypeProvider,
                                                                            subBendy,
                                                                            dynamicExtensionAssemblies);

                    BendyObjectExtensionsHelper.ApplyDynamicExtensions <TypedAttribute>(subBendy, dynamicExtensionAssemblies);

                    AddToBendy(bendy, attrib.AttributeDefinition.Alias, subBendy);
                }
                else
                {
                    AddToBendy(bendy, attrib.AttributeDefinition.Alias, defaultval);
                }
            }

            // Now put in rudimentary default values for any that don't have a value
            // TODO: Get the default values from the backoffice/AttributeDefinition/AttributeType involved in this
            foreach (var attrib in content.Attributes.Except(attributesWithValue))
            {
                object defaultValue = null;
                switch (attrib.AttributeDefinition.AttributeType.SerializationType.DataSerializationType)
                {
                case DataSerializationTypes.Date:
                    defaultValue = DateTime.MinValue;
                    break;

                case DataSerializationTypes.Guid:
                    defaultValue = Guid.Empty;
                    break;

                case DataSerializationTypes.SmallInt:
                case DataSerializationTypes.LargeInt:
                    defaultValue = 0;
                    break;

                case DataSerializationTypes.Decimal:
                    defaultValue = 0d;
                    break;

                case DataSerializationTypes.ByteArray:
                    defaultValue = new byte[] { };
                    break;

                case DataSerializationTypes.Boolean:
                    defaultValue = false;
                    break;

                case DataSerializationTypes.String:
                case DataSerializationTypes.LongString:
                    defaultValue = string.Empty;
                    break;
                }
                AddToBendy(bendy, attrib.AttributeDefinition.Alias, defaultValue);
            }

            bendy["__OriginalItem"] = content;

            bendy.WhenItemNotFound = (bent, membername) =>
            {
                if (membername.IsNullOrWhiteSpace())
                {
                    return(new BendyObject());
                }
                // Support recursively looking up a property similarly to v4
                if (membername.StartsWith("_") && membername.ElementAt(1).IsLowerCase())
                {
                    return(content.Field(membername.TrimStart('_'), true));
                }
                // Support pluralised document-type aliases inferring a query
                if (membername.EndsWith("s", StringComparison.InvariantCultureIgnoreCase))
                {
                    var alias = membername.TrimEnd("s");
                    var up    = alias.StartsWith("Ancestor", StringComparison.InvariantCultureIgnoreCase);
                    if (up)
                    {
                        alias = alias.TrimStart("Ancestor");
                    }
                    dynamic theBendy = bent;

                    return(up ? theBendy.AncestorsOrSelf.Where("NodeTypeAlias == @0", alias) : theBendy.DescendantsOrSelf.Where("NodeTypeAlias == @0", alias));
                }
                return(new BendyObject());
            };

            bendy.AddLazy("AllAncestorIds", () => content.AllAncestorIds());
            bendy.AddLazy("Ancestors", () =>
            {
                var ancestorIds = content.AllAncestorIds();
                return(new DynamicContentList(content.Id, hiveManager, membershipService, publicAccessService, new BendyObject(), ancestorIds));
            });
            bendy.AddLazy("AllAncestorIdsOrSelf", () => content.AllAncestorIdsOrSelf());
            bendy.AddLazy("AncestorsOrSelf", () =>
            {
                var ancestorIds = content.AllAncestorIdsOrSelf();
                return(new DynamicContentList(content.Id, hiveManager, membershipService, publicAccessService, new BendyObject(), ancestorIds));
            });
            bendy.AddLazy("AllDescendantIds", () => content.AllDescendantIds());
            bendy.AddLazy("Descendants", () =>
            {
                var descendantContentIds = content.AllDescendantIds();
                return(new DynamicContentList(content.Id, hiveManager, membershipService, publicAccessService, new BendyObject(), descendantContentIds));
            });
            bendy.AddLazy("AllDescendantIdsOrSelf", () => content.AllDescendantIdsOrSelf());
            bendy.AddLazy("DescendantsOrSelf", () =>
            {
                var descendantContentIds = content.AllDescendantIdsOrSelf();
                return(new DynamicContentList(content.Id, hiveManager, membershipService, publicAccessService, new BendyObject(), descendantContentIds));
            });
            bendy.AddLazy("AllChildIds", () => content.AllChildIds(hiveManager));
            bendy.AddLazy("Children", () =>
            {
                var childIds = content.AllChildIds(hiveManager);
                return(new DynamicContentList(content.Id, hiveManager, membershipService, publicAccessService, new BendyObject(), childIds));
            });
            bendy.AddLazy("Parent", () => content.ParentContent(hiveManager).Bend(hiveManager, membershipService, publicAccessService));
            bendy.AddLazy("Path", () => content.GetPath(hiveManager));
            bendy.AddLazy("PathById", () => content.GetPath(hiveManager));
            bendy.AddLazy("Level", () => content.GetPath(hiveManager).Level);

            //Add lazy url property
            bendy.AddLazy("Url", content.NiceUrl);
            bendy.AddLazy("NiceUrl", content.NiceUrl);
            bendy.AddLazy("NodeTypeAlias", () => content.ContentType.IfNotNull(x => x.Alias, string.Empty));
            bendy.AddLazy("Template", () => content.CurrentTemplate.IfNotNull(x => x.Alias, string.Empty));
            bendy.AddLazy("TemplateId", () => content.CurrentTemplate.IfNotNull(x => x.Id, HiveId.Empty));
            bendy.AddLazy("TemplateFileName", () => content.CurrentTemplate.IfNotNull(x => (string)x.Id.Value, string.Empty));
            bendy.AddLazy("CreateDate", () => content.UtcCreated);
            bendy.AddLazy("UpdateDate", () => content.UtcModified);
            bendy.AddLazy("StatusChangedDate", () => content.UtcStatusChanged);

            dynamicBendy.ContentType = content.ContentType;
            var nodeNameAlias = NodeNameAttributeDefinition.AliasValue.ToRebelAlias(StringAliasCaseType.PascalCase);

            try
            {
                dynamicBendy.Name    = bendy[nodeNameAlias].Name;
                dynamicBendy.UrlName = bendy[nodeNameAlias].UrlName;
            }
            catch
            {
                /* Nothing */
            }

            dynamicBendy.Id = content.Id;

            // Add any dynamic registered methods
            BendyObjectExtensionsHelper.ApplyDynamicExtensions <Content>(bendy, dynamicExtensionAssemblies);

            return(dynamicBendy);
        }
 private void PublicAccessService_Deleted(IPublicAccessService sender, DeleteEventArgs <PublicAccessEntry> e)
 {
     _distributedCache.RefreshPublicAccess();
 }
 /// <summary>
 /// Filters the with public access.
 /// </summary>
 /// <param name="entityIds">The entity ids.</param>
 /// <param name="member">The member.</param>
 /// <param name="publicAccessService">The public access service.</param>
 /// <returns></returns>
 public static IEnumerable<HiveId> FilterWithPublicAccess(this IEnumerable<HiveId> entityIds,
     Member member,
     IPublicAccessService publicAccessService)
 {
     return entityIds.FilterWithPublicAccess(member == null ? HiveId.Empty : member.Id, publicAccessService);
 }
 public ContextComponent(IUmbracoContextFactory context, IScopeProvider scopeProvider, IContentService contentService, IContentTypeService contentTypeService, IDataTypeService dataTypeService, IFileService fileService, IMediaTypeService mediaTypeService, IMediaService mediaService, IUserService userService, IDomainService domainService, IPublicAccessService publicAccessService, IAuditService auditService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, ITagService tagService, IMemberService memberService, IUmbracoContextFactory contextFactory, ILogger logger)
 {
     ConnectorContext.ScopeProvider        = scopeProvider;
     ConnectorContext.ContentService       = contentService;
     ConnectorContext.ContentTypeService   = contentTypeService;
     ConnectorContext.DataTypeService      = dataTypeService;
     ConnectorContext.FileService          = fileService;
     ConnectorContext.MediaTypeService     = mediaTypeService;
     ConnectorContext.MediaService         = mediaService;
     ConnectorContext.UserService          = userService;
     ConnectorContext.DomainService        = domainService;
     ConnectorContext.PublicAccessService  = publicAccessService;
     ConnectorContext.AuditService         = auditService;
     ConnectorContext.LocalizationService  = localizationService;
     ConnectorContext.LocalizedTextService = localizedTextService;
     ConnectorContext.TagService           = tagService;
     ConnectorContext.MemberService        = memberService;
     ConnectorContext.UmbracoContext       = context.EnsureUmbracoContext().UmbracoContext;
     ConnectorContext.ContextFactory       = contextFactory;
     ConnectorContext.Logger = logger;
 }
示例#21
0
 public UmbracoIndexConfig(IPublicAccessService publicAccessService)
 {
     PublicAccessService = publicAccessService;
 }
示例#22
0
        /// <summary>
        /// Creates a partial service context with only some services (for tests).
        /// </summary>
        /// <remarks>
        /// <para>Using a true constructor for this confuses DI containers.</para>
        /// </remarks>
        public static ServiceContext CreatePartial(
            IContentService contentService         = null,
            IMediaService mediaService             = null,
            IContentTypeService contentTypeService = null,
            IMediaTypeService mediaTypeService     = null,
            IDataTypeService dataTypeService       = null,
            IFileService fileService = null,
            ILocalizationService localizationService = null,
            IPackagingService packagingService       = null,
            IEntityService entityService             = null,
            IRelationService relationService         = null,
            IMemberGroupService memberGroupService   = null,
            IMemberTypeService memberTypeService     = null,
            IMemberService memberService             = null,
            IUserService userService = null,
            ITagService tagService   = null,
            INotificationService notificationService   = null,
            ILocalizedTextService localizedTextService = null,
            IAuditService auditService                                     = null,
            IDomainService domainService                                   = null,
            IMacroService macroService                                     = null,
            IPublicAccessService publicAccessService                       = null,
            IExternalLoginService externalLoginService                     = null,
            IServerRegistrationService serverRegistrationService           = null,
            IRedirectUrlService redirectUrlService                         = null,
            IConsentService consentService                                 = null,
            IKeyValueService keyValueService                               = null,
            IContentTypeBaseServiceProvider contentTypeBaseServiceProvider = null)
        {
            Lazy <T> Lazy <T>(T service) => service == null ? null : new Lazy <T>(() => service);

            return(new ServiceContext(
                       Lazy(publicAccessService),
                       Lazy(domainService),
                       Lazy(auditService),
                       Lazy(localizedTextService),
                       Lazy(tagService),
                       Lazy(contentService),
                       Lazy(userService),
                       Lazy(memberService),
                       Lazy(mediaService),
                       Lazy(contentTypeService),
                       Lazy(mediaTypeService),
                       Lazy(dataTypeService),
                       Lazy(fileService),
                       Lazy(localizationService),
                       Lazy(packagingService),
                       Lazy(serverRegistrationService),
                       Lazy(entityService),
                       Lazy(relationService),
                       Lazy(macroService),
                       Lazy(memberTypeService),
                       Lazy(memberGroupService),
                       Lazy(notificationService),
                       Lazy(externalLoginService),
                       Lazy(redirectUrlService),
                       Lazy(consentService),
                       Lazy(keyValueService),
                       Lazy(contentTypeBaseServiceProvider)
                       ));
        }
示例#23
0
        protected static dynamic BendIfPossible(TypedEntity entity, IHiveManager hiveManager,
                                                IMembershipService <Member> membershipService, IPublicAccessService publicAccessService, object defaultValueIfNull)
        {
            var asContent = MapIfPossible(entity, hiveManager.FrameworkContext.TypeMappers);

            if (asContent == null)
            {
                return(defaultValueIfNull);
            }
            return(asContent.Bend(hiveManager, membershipService, publicAccessService));
        }
示例#24
0
 public UmbracoIndexCreator(IProfilingLogger profilingLogger, ILocalizationService languageService, IPublicAccessService publicAccessService, IMemberService memberService)
     : base(profilingLogger, languageService, publicAccessService, memberService)
 {
     _publicAccessService = publicAccessService;
 }
示例#25
0
        public DynamicContentList(HiveId sourceId, IHiveManager hiveManager, IMembershipService <Member> membershipService, IPublicAccessService publicAccessService,
                                  object defaultValueIfNull, IEnumerable <HiveId> containedIds, IQueryable <TypedEntity> chainedExpression)
        {
            _containedIds        = containedIds;
            _defaultValueIfNull  = defaultValueIfNull;
            _hiveManager         = hiveManager;
            _membershipService   = membershipService;
            _publicAccessService = publicAccessService;
            _sourceId            = sourceId;
            _queryProvider       = chainedExpression;

            if (!containedIds.Any())
            {
                _queryProvider = Enumerable.Empty <Content>().AsQueryable();
            }
        }
 public static bool HasAccess(this IPublicAccessService publicAccessService, string path, MembershipUser member, RoleProvider roleProvider)
 {
     return(publicAccessService.HasAccess(path, member.UserName, roleProvider.GetRolesForUser));
 }
示例#27
0
 public PublicAccessChecker(IHttpContextAccessor httpContextAccessor, IPublicAccessService publicAccessService, IContentService contentService)
 {
     _httpContextAccessor = httpContextAccessor;
     _publicAccessService = publicAccessService;
     _contentService      = contentService;
 }
示例#28
0
 /// <summary>
 /// Filters the with public access.
 /// </summary>
 /// <param name="entityIds">The entity ids.</param>
 /// <param name="member">The member.</param>
 /// <param name="publicAccessService">The public access service.</param>
 /// <returns></returns>
 public static IEnumerable <HiveId> FilterWithPublicAccess(this IEnumerable <HiveId> entityIds,
                                                           Member member,
                                                           IPublicAccessService publicAccessService)
 {
     return(entityIds.FilterWithPublicAccess(member == null ? HiveId.Empty : member.Id, publicAccessService));
 }
 public CustomIndexConfig(IPublicAccessService publicAccessService,
                          IScopeProvider scopeProvider) : base(publicAccessService)
 {
     _publicAccessService = publicAccessService;
     _scopeProvider       = scopeProvider;
 }
示例#30
0
 public CustomIndexConfig(IPublicAccessService publicAccessService) : base(publicAccessService)
 {
 }
示例#31
0
 public DynamicContentEnumerator(IEnumerator <TypedEntity> innerEnumerator, IHiveManager hiveManager,
                                 IMembershipService <Member> membershipService, IPublicAccessService publicAccessService, object defaultValueIfNull)
     : base(innerEnumerator)
 {
     _membershipService   = membershipService;
     _publicAccessService = publicAccessService;
     _defaultValueIfNull  = defaultValueIfNull;
     HiveManager          = hiveManager;
 }
示例#32
0
 public UmbracoIndexConfig(IPublicAccessService publicAccessService, IScopeProvider scopeProvider)
 {
     ScopeProvider       = scopeProvider;
     PublicAccessService = publicAccessService;
 }
示例#33
0
 /// <summary>
 /// public ctor - will generally just be used for unit testing all items are optional and if not specified, the defaults will be used
 /// </summary>
 /// <param name="contentService"></param>
 /// <param name="mediaService"></param>
 /// <param name="contentTypeService"></param>
 /// <param name="dataTypeService"></param>
 /// <param name="fileService"></param>
 /// <param name="localizationService"></param>
 /// <param name="packagingService"></param>
 /// <param name="entityService"></param>
 /// <param name="relationService"></param>
 /// <param name="memberGroupService"></param>
 /// <param name="memberTypeService"></param>
 /// <param name="memberService"></param>
 /// <param name="userService"></param>
 /// <param name="sectionService"></param>
 /// <param name="treeService"></param>
 /// <param name="tagService"></param>
 /// <param name="notificationService"></param>
 /// <param name="localizedTextService"></param>
 /// <param name="auditService"></param>
 /// <param name="domainService"></param>
 /// <param name="taskService"></param>
 /// <param name="macroService"></param>
 /// <param name="publicAccessService"></param>
 /// <param name="externalLoginService"></param>
 /// <param name="migrationEntryService"></param>
 public ServiceContext(
     IContentService contentService         = null,
     IMediaService mediaService             = null,
     IContentTypeService contentTypeService = null,
     IDataTypeService dataTypeService       = null,
     IFileService fileService = null,
     ILocalizationService localizationService = null,
     IPackagingService packagingService       = null,
     IEntityService entityService             = null,
     IRelationService relationService         = null,
     IMemberGroupService memberGroupService   = null,
     IMemberTypeService memberTypeService     = null,
     IMemberService memberService             = null,
     IUserService userService            = null,
     ISectionService sectionService      = null,
     IApplicationTreeService treeService = null,
     ITagService tagService = null,
     INotificationService notificationService   = null,
     ILocalizedTextService localizedTextService = null,
     IAuditService auditService                   = null,
     IDomainService domainService                 = null,
     ITaskService taskService                     = null,
     IMacroService macroService                   = null,
     IPublicAccessService publicAccessService     = null,
     IExternalLoginService externalLoginService   = null,
     IMigrationEntryService migrationEntryService = null)
 {
     if (migrationEntryService != null)
     {
         _migrationEntryService = new Lazy <IMigrationEntryService>(() => migrationEntryService);
     }
     if (externalLoginService != null)
     {
         _externalLoginService = new Lazy <IExternalLoginService>(() => externalLoginService);
     }
     if (auditService != null)
     {
         _auditService = new Lazy <IAuditService>(() => auditService);
     }
     if (localizedTextService != null)
     {
         _localizedTextService = new Lazy <ILocalizedTextService>(() => localizedTextService);
     }
     if (tagService != null)
     {
         _tagService = new Lazy <ITagService>(() => tagService);
     }
     if (contentService != null)
     {
         _contentService = new Lazy <IContentService>(() => contentService);
     }
     if (mediaService != null)
     {
         _mediaService = new Lazy <IMediaService>(() => mediaService);
     }
     if (contentTypeService != null)
     {
         _contentTypeService = new Lazy <IContentTypeService>(() => contentTypeService);
     }
     if (dataTypeService != null)
     {
         _dataTypeService = new Lazy <IDataTypeService>(() => dataTypeService);
     }
     if (fileService != null)
     {
         _fileService = new Lazy <IFileService>(() => fileService);
     }
     if (localizationService != null)
     {
         _localizationService = new Lazy <ILocalizationService>(() => localizationService);
     }
     if (packagingService != null)
     {
         _packagingService = new Lazy <IPackagingService>(() => packagingService);
     }
     if (entityService != null)
     {
         _entityService = new Lazy <IEntityService>(() => entityService);
     }
     if (relationService != null)
     {
         _relationService = new Lazy <IRelationService>(() => relationService);
     }
     if (sectionService != null)
     {
         _sectionService = new Lazy <ISectionService>(() => sectionService);
     }
     if (memberGroupService != null)
     {
         _memberGroupService = new Lazy <IMemberGroupService>(() => memberGroupService);
     }
     if (memberTypeService != null)
     {
         _memberTypeService = new Lazy <IMemberTypeService>(() => memberTypeService);
     }
     if (treeService != null)
     {
         _treeService = new Lazy <IApplicationTreeService>(() => treeService);
     }
     if (memberService != null)
     {
         _memberService = new Lazy <IMemberService>(() => memberService);
     }
     if (userService != null)
     {
         _userService = new Lazy <IUserService>(() => userService);
     }
     if (notificationService != null)
     {
         _notificationService = new Lazy <INotificationService>(() => notificationService);
     }
     if (domainService != null)
     {
         _domainService = new Lazy <IDomainService>(() => domainService);
     }
     if (taskService != null)
     {
         _taskService = new Lazy <ITaskService>(() => taskService);
     }
     if (macroService != null)
     {
         _macroService = new Lazy <IMacroService>(() => macroService);
     }
     if (publicAccessService != null)
     {
         _publicAccessService = new Lazy <IPublicAccessService>(() => publicAccessService);
     }
 }
示例#34
0
 static void PublicAccessService_Deleted(IPublicAccessService sender, DeleteEventArgs <PublicAccessEntry> e)
 {
     DistributedCache.Instance.RefreshPublicAccess();
 }
示例#35
0
 public PublicAccessHandler(IPublicAccessService publicAccessService) =>