public void Create_EffectiveAuthorization_Without_EffectiveAuthorizationEvent_InStorage_Returns_Timeline_With_EffectiveAuthorization()
        {
            //Arrange
            var eaEventsStorate  = new RawEventInMemoryStorage();
            var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory();

            eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());

            var owner = new ExternalId()
            {
                Id = _defaultId, Context = _defaultContext
            };
            var permission = new Permission()
            {
                Application = _defaultApplication, Id = _defaultPermissionId, Description = _defaultDescription
            };
            var effectiveAuthorization = new EffectiveAuthorization()
            {
                TenantId = _tenantId, Permission = permission, User = owner
            };

            var eaTimelineFactory = new EffectiveAuthorizationTimelineFactory(eaEventsStorate, eaHandlerFactory);

            //Act
            var eaTimeline = eaTimelineFactory.Create(effectiveAuthorization).Result;

            //Assert
            Assert.IsNotNull(eaTimeline);
            Assert.AreEqual(effectiveAuthorization, eaTimeline.EffectiveAuthorization);
        }
Пример #2
0
        public static void ConfigureServices(IServiceCollection services)
        {
            var rawEventInMemoryStore = new RawEventInMemoryStorage();

            services.AddSingleton <IWriteRawEventStorage>(provider => rawEventInMemoryStore);
            services.AddSingleton <IReadRawEventStorage>(provider => rawEventInMemoryStore);

            services.AddTransient <IDataEnrichmentService, DataEnrichmentService>();

            services.AddTransient <IEffectiveAuthorizationTimelineFactory, EffectiveAuthorizationTimelineFactory>();
            services.AddSingleton <IEffectiveAuthorizationHandlerFactory>(s =>
            {
                var factory = new EffectiveAuthorizationHandlerFactory();
                factory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());
                factory.RegisterHandler(typeof(EffectiveAuthorizationRevokedEvent), new PermissionRevokedHandler());
                return(factory);
            });

            services.AddSingleton <ILogger, MockInMemoryLogger>();
            services.AddTransient <IPersonalInfoEnrichmentService, PersonalInfoEnrichmentService>();
            services.AddTransient <IPersonLocalStorage, MockPersonalLocalStorage>();
            services.AddTransient <IPersonalInfoExternalServiceFactory, MockPersonalInfoExternalServiceFactory>();

            services.AddSingleton <IReportingStorage, ReportingInMemoryStorage>();
        }
Пример #3
0
        public async Task AddEffectiveAuthorizationAsync_Event_Stored_With_Invalid_Authorization_No_Permission_Throws_NullReferenceException()
        {
            //Arrange
            var eaEventsStorate = new RawEventInMemoryStorage();

            var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory();

            eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());

            var eatimelineFactory = new EffectiveAuthorizationTimelineFactory(eaEventsStorate, eaHandlerFactory);

            var prService = new PersonalInfoEnrichmentService(new MockPersonalLocalStorage(), new MockPersonalInfoExternalServiceFactory(), new MockInMemoryLogger());
            var rpStorage = new ReportingInMemoryStorage();

            var permission = new Permission()
            {
                Application = _defaultApplication, Id = _defaultPermissionId, Description = _defaultDescription
            };
            var effectiveAuthorization = new EffectiveAuthorization()
            {
                TenantId = _tenantId, Permission = permission
            };
            var eaEvent = new EffectiveAuthorizationGrantedEvent()
            {
                From = new DateTime(2018, 1, 1), EffectiveAuthorization = effectiveAuthorization
            };

            await eaEventsStorate.WriteRawEventAsync(eaEvent); //event needs to be previously writteng to storage.

            var dataEnrichmentService = new DataEnrichmentService(eatimelineFactory, prService, rpStorage);

            //Act & Assert
            await Assert.ThrowsExceptionAsync <NullReferenceException>(() => dataEnrichmentService.AddEffectiveAuthorizationAsync(eaEvent));
        }
        public void GetHandler_Unregistered_Handler_Returns_InvalidOperationException()
        {
            //Arrange
            var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory();

            //Act & Assert
            Assert.ThrowsException <InvalidOperationException>(() => { eaHandlerFactory.GetHandler(new EffectiveAuthorizationGrantedEvent()); });
        }
Пример #5
0
        public async Task AddEffectiveAuthorizationAsync_GrantedAndRevokedEventsForUnexistingUserContextAndWithoutTarget_ClosedIntervalIsCreatedInReadModelWithoutEnrichedPersonalInfo()
        {
            //Create a raw event
            var user = new ExternalId()
            {
                Context = "unexistingContext", Id = _userId
            };
            var permission = new Permission()
            {
                Application = "YOUFORCE", Id = "HomeAccess", Description = ""
            };
            var effectiveAuthorization = new EffectiveAuthorization()
            {
                TenantId = _tenantId, Permission = permission, User = user
            };

            var eaGrantedEvent = new EffectiveAuthorizationGrantedEvent()
            {
                From = _from, EffectiveAuthorization = effectiveAuthorization, DateCreated = DateTime.Now
            };
            var eaRevokedEvent = new EffectiveAuthorizationRevokedEvent()
            {
                Until = _until, EffectiveAuthorization = effectiveAuthorization, DateCreated = DateTime.Now
            };


            _eventIdList.Add(await _repository.WriteRawEventAsync(eaGrantedEvent));
            _eventIdList.Add(await _repository.WriteRawEventAsync(eaRevokedEvent));

            //Data Enrichment
            var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory();

            eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationRevokedEvent), new PermissionRevokedHandler());
            eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());
            var eatimelineFactory = new EffectiveAuthorizationTimelineFactory(_repository, eaHandlerFactory);

            var logger    = new MockInMemoryLogger();
            var prService = PersonalInfoEnrichmentServiceHelper.BuildService(logger);
            var readModel = new ReportingInMemoryStorage();

            var dataEnrichmentService = new DataEnrichmentService(eatimelineFactory, prService, readModel);

            await dataEnrichmentService.AddEffectiveAuthorizationAsync(eaRevokedEvent);

            //Assertions
            var expectedUser = new Person(user, null);
            var intervals    = readModel.GetIntervals(effectiveAuthorization).Result;

            Assert.AreEqual(1, intervals.Count);
            Assert.AreEqual(_tenantId, intervals[0].TenantId);
            Assert.AreEqual(user, intervals[0].User.Key);
            Assert.IsNull(intervals[0].User.PersonalInfo);
            Assert.AreEqual(permission, intervals[0].Permission);
            Assert.AreEqual(null, intervals[0].TargetPerson);
            Assert.AreEqual(_from, intervals[0].EffectiveInterval.Start);
            Assert.AreEqual(_until, intervals[0].EffectiveInterval.End);
        }
Пример #6
0
        public async Task AddEffectiveAuthorizationAsync_GrantedEventForExistingUserAndTarget_OpenIntervalIsCreatedInReadModelWithEnrichedPersonalInfo()
        {
            //Create a raw event
            var user = new ExternalId()
            {
                Context = _context, Id = _userId
            };
            var permission = new Permission()
            {
                Application = "YOUFORCE", Id = "HomeAccess", Description = "Home Access"
            };
            var target = new ExternalId()
            {
                Id = _targetId, Context = _context
            };
            var effectiveAuthorization = new EffectiveAuthorization()
            {
                TenantId = _tenantId, Permission = permission, User = user, Target = target
            };
            var eaEvent = new EffectiveAuthorizationGrantedEvent()
            {
                From = _from, EffectiveAuthorization = effectiveAuthorization, DateCreated = DateTime.Now
            };

            //Add event to the memory event store
            _eventIdList.Add(await _repository.WriteRawEventAsync(eaEvent));

            //Data Enrichment
            var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory();

            eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());
            var eatimelineFactory = new EffectiveAuthorizationTimelineFactory(_repository, eaHandlerFactory);

            var logger    = new MockInMemoryLogger();
            var prService = PersonalInfoEnrichmentServiceHelper.BuildService(logger);
            var readModel = new ReportingInMemoryStorage();

            var dataEnrichmentService = new DataEnrichmentService(eatimelineFactory, prService, readModel);

            await dataEnrichmentService.AddEffectiveAuthorizationAsync(eaEvent);

            //Assertions
            var expectedUser   = new Person(user, _userPersonalInfo);
            var expectedTarget = new Person(target, _targetPersonalInfo);
            var intervals      = readModel.GetIntervals(effectiveAuthorization).Result;

            Assert.AreEqual(1, intervals.Count);
            Assert.AreEqual(_tenantId, intervals[0].TenantId);
            Assert.AreEqual(expectedUser, intervals[0].User);
            Assert.AreEqual(permission, intervals[0].Permission);
            Assert.AreEqual(expectedTarget, intervals[0].TargetPerson);
            Assert.AreEqual(_from, intervals[0].EffectiveInterval.Start);
        }
        public void GetHandler_Registered_Handler_Right_Event_Type_Returns_Handler()
        {
            //Arrange
            var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory();

            eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());

            //Act
            var handler = eaHandlerFactory.GetHandler(new EffectiveAuthorizationGrantedEvent());

            //Assert
            Assert.IsInstanceOfType(handler, typeof(PermissionGrantedHandler));
        }
Пример #8
0
        public async Task AddEffectiveAuthorizationAsync_Event_Stored_With_Valid_Authorization_Without_Target_Stores_Correct_Information()
        {
            //Arrange
            var eaEventsStorate = new RawEventInMemoryStorage();

            var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory();

            eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());

            var eatimelineFactory = new EffectiveAuthorizationTimelineFactory(eaEventsStorate, eaHandlerFactory);

            var prService = new PersonalInfoEnrichmentService(new MockPersonalLocalStorage(), new MockPersonalInfoExternalServiceFactory(), new MockInMemoryLogger());

            var rpStorage = new ReportingInMemoryStorage();
            var owner     = new ExternalId()
            {
                Id = _defaultId, Context = _defaultContext
            };
            var permission = new Permission()
            {
                Application = _defaultApplication, Id = _defaultPermissionId, Description = _defaultDescription
            };
            var effectiveAuthorization = new EffectiveAuthorization()
            {
                TenantId = _tenantId, Permission = permission, User = owner
            };
            var eaEvent = new EffectiveAuthorizationGrantedEvent()
            {
                From = new DateTime(2018, 1, 1), EffectiveAuthorization = effectiveAuthorization
            };

            await eaEventsStorate.WriteRawEventAsync(eaEvent); //event needs to be previously writteng to storage.

            var dataEnrichmentService = new DataEnrichmentService(eatimelineFactory, prService, rpStorage);

            //Act
            await dataEnrichmentService.AddEffectiveAuthorizationAsync(eaEvent);

            var intervals = await rpStorage.GetIntervals(effectiveAuthorization);

            //Assert
            Assert.AreEqual(1, intervals.Count);
            Assert.AreEqual(_tenantId, intervals[0].TenantId);
            Assert.AreEqual(owner, intervals[0].User.Key);
            Assert.AreEqual(permission, intervals[0].Permission);
            Assert.AreEqual(null, intervals[0].TargetPerson);
        }
Пример #9
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            IConfiguration configuration = builder.Services.BuildServiceProvider().GetRequiredService <IConfiguration>();

            builder.Services
            .AddCustomLogging()
            .AddConfigurations <CosmoDBSettings>(configuration, "CosmosReadDb")
            .AddConfigurations <CosmoDBSettings>(configuration, "CosmosWriteDb")
            .AddSingleton <ITableStorageSettings>(x => configuration.GetSection("TableStorageSettings").Get <TableStorageSettings>())
            .AddSingleton <IAzureTableStorageInitializer, AzureTableStorageInitializer>()

            .AddCustomTableStorage <StoredPersonalInfo>()
            .AddCustomTableStorage <ContextMapping>()
            .AddStorageRepository(configuration)

            .AddSingleton <IRestSharp, RestSharpHelper>()
            .AddSingleton <ICosmoDBStorageInitializer, CosmoDBStorageInitializer>()
            .AddSingleton <IEffectiveAuthorizationHandlerFactory>(s =>
            {
                var factory = new EffectiveAuthorizationHandlerFactory();
                factory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());
                factory.RegisterHandler(typeof(EffectiveAuthorizationRevokedEvent), new PermissionRevokedHandler());
                return(factory);
            })
            .AddScoped <IPersonLocalStorage, PersonLocalStorage>()
            .AddScoped <IContextMappingLocalStorage, ContextMappingLocalStorage>()
            .AddScoped <IEffectiveAuthorizationTimelineFactory, EffectiveAuthorizationTimelineFactory>()

            .AddScoped <IDataEnrichmentBusiness, DataEnrichmentBusiness>()
            .AddScoped <IUserInformation, UserInformation>();


            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.AddProfile <ExternalIdProfile>();
                cfg.AddProfile <PermissionProfile>();
                cfg.AddProfile <EffectiveAuthorizationProfile>();
                cfg.AddProfile <EffectiveAuthorizationGrantedEventProfile>();
                cfg.AddProfile <EffectiveAuthorizationRevokedEventProfile>();
            });
        }
Пример #10
0
        public async Task AddEffectiveAuthorizationAsync_Event_Stored_With_Valid_Authorization_Without_Target_Calls_IReportingStorage_SaveAsyc()
        {
            //Arrange
            var eaEventsStorate = new RawEventInMemoryStorage();

            var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory();

            eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());

            var eatimelineFactory = new EffectiveAuthorizationTimelineFactory(eaEventsStorate, eaHandlerFactory);

            var prService = new PersonalInfoEnrichmentService(new MockPersonalLocalStorage(), new MockPersonalInfoExternalServiceFactory(), new MockInMemoryLogger());

            var rpStorageMock = new Mock <IReportingStorage>();
            var owner         = new ExternalId()
            {
                Id = _defaultId, Context = _defaultContext
            };
            var permission = new Permission()
            {
                Application = _defaultApplication, Id = _defaultPermissionId, Description = _defaultDescription
            };
            var effectiveAuthorization = new EffectiveAuthorization()
            {
                TenantId = _tenantId, Permission = permission, User = owner
            };
            var eaEvent = new EffectiveAuthorizationGrantedEvent()
            {
                From = new DateTime(2018, 1, 1), EffectiveAuthorization = effectiveAuthorization
            };

            await eaEventsStorate.WriteRawEventAsync(eaEvent); //event needs to be previously writteng to storage.

            var dataEnrichmentService = new DataEnrichmentService(eatimelineFactory, prService, rpStorageMock.Object);

            //Act
            await dataEnrichmentService.AddEffectiveAuthorizationAsync(eaEvent);

            //Assert
            rpStorageMock.Verify(v => v.SaveAsync(It.IsAny <IList <EffectiveAuthorizationInterval> >()));
        }
Пример #11
0
        public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
        {
            services.AddSingleton <IEventBus, MemoryEventBus>();
            services.AddTransient <IEffectiveAuthorizationLogging, HybridEffectiveAuthorizationLogging>();

            // TODO: discuss whether this is correct. In particular, configuration is being build every single time the
            //       a request is created....
            services.AddTransient <IWriteRawEventStorage, RawEventStorageRepository>();
            services.AddTransient <IDataEnrichmentService, DataEnrichmentService>();
            services.AddTransient <IEffectiveAuthorizationTimelineFactory, EffectiveAuthorizationTimelineFactory>();
            services.AddSingleton <IEffectiveAuthorizationHandlerFactory>(s =>
            {
                var factory = new EffectiveAuthorizationHandlerFactory();
                factory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());
                factory.RegisterHandler(typeof(EffectiveAuthorizationRevokedEvent), new PermissionRevokedHandler());
                return(factory);
            });

            services.AddTransient <IPersonalInfoEnrichmentService, PersonalInfoEnrichmentService>();
            // TODO: Missing implementations
        }
Пример #12
0
        public static IServiceCollection AddInitialLoadDependency(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddScoped <IInitialLoadFileUploadBusiness, InitialLoadFileUploadBusiness>();
            services.AddScoped <IInitialLoadBusiness, InitialLoadBusiness>()
            .AddCustomTableStorage <StoredPersonalInfo>()
            .AddCustomTableStorage <ContextMapping>();

            services.AddSingleton <IRestSharp, RestSharpHelper>()
            .AddSingleton <IEffectiveAuthorizationHandlerFactory>(s =>
            {
                var factory = new EffectiveAuthorizationHandlerFactory();
                factory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());
                factory.RegisterHandler(typeof(EffectiveAuthorizationRevokedEvent), new PermissionRevokedHandler());
                return(factory);
            })
            .AddScoped <IPersonLocalStorage, PersonLocalStorage>()
            .AddScoped <IContextMappingLocalStorage, ContextMappingLocalStorage>()
            .AddScoped <IEffectiveAuthorizationTimelineFactory, EffectiveAuthorizationTimelineFactory>()
            .AddScoped <IUserInformation, UserInformation>();

            services.AddScoped <IWriteRawEventStorage>(c =>
            {
                var cosmosDbSettings = configuration.GetSection("CosmosReadDb").Get <CosmoDBSettings>();
                var log = c.GetRequiredService <ILogger>();
                return(new InitialLoadStorageRepository(GetCosmoCollectionSettings(cosmosDbSettings), log));
            });

            services.AddScoped <IReadRawEventStorage>(c =>
            {
                var cosmosDbSettings = configuration.GetSection("CosmosReadDb").Get <CosmoDBSettings>();
                var log = c.GetRequiredService <ILogger>();
                return(new RawEventStorageRepository(GetCosmoCollectionSettings(cosmosDbSettings), log));
            });

            services.AddScoped <IReportingStorage>(c =>
            {
                var cosmosDbSettings = configuration.GetSection("CosmoDBSettings").Get <CosmoDBSettings>();
                var log = c.GetRequiredService <ILogger>();
                return(new ReportingStorageRepository(GetCosmoCollectionSettings(cosmosDbSettings), log));
            });

            services.AddScoped <IDataEnrichmentBusiness>(c =>
            {
                var cosmosReadDbSettings  = configuration.GetSection("CosmosReadDb").Get <CosmoDBSettings>();
                var cosmosWriteDbSettings = configuration.GetSection("CosmoDBSettings").Get <CosmoDBSettings>();
                var log              = c.GetRequiredService <ILogger>();
                var logFactory       = c.GetRequiredService <ILoggerFactory>();
                var reportingStorage = c.GetRequiredService <IReportingStorage>();
                var effectiveAuthorizationHandlerFactory = c.GetRequiredService <IEffectiveAuthorizationHandlerFactory>();
                var userInformation = c.GetRequiredService <IUserInformation>();
                return(new DataEnrichmentBusiness(GetEffectiveAuthorizationTimelineFactory(GetreadRawEventStorage(GetCosmoCollectionSettings(cosmosReadDbSettings), log),
                                                                                           effectiveAuthorizationHandlerFactory), GetReportingStorage(GetCosmoCollectionSettings(cosmosWriteDbSettings), log), userInformation, log));
            });

            services.AddScoped <IReportingBusiness>(c =>
            {
                var log = c.GetRequiredService <ILogger>();
                var reportingStorage                  = c.GetRequiredService <IReportingStorage>();
                var fileInformationRepository         = c.GetRequiredService <IAzureTableStorageRepository <FileInformation> >();
                var checksumGenerator                 = c.GetRequiredService <IChecksumGenerator>();
                var azureQueueStorageRepository       = c.GetRequiredService <IAzureQueueStorageRepository>();
                var generateReportBlobStorageSettings = configuration.GetSection("GenerateReportBlobStorageSettings").Get <BlobStorageSettings>();
                return(new ReportingBusiness(reportingStorage, GetAzureBlobStorageRepository(GetAzureBlobStorageInitializer(generateReportBlobStorageSettings, log), log),
                                             fileInformationRepository, checksumGenerator, generateReportBlobStorageSettings, azureQueueStorageRepository, log));
            });

            return(services);
        }
Пример #13
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            IConfiguration configuration = builder.Services.BuildServiceProvider().GetRequiredService <IConfiguration>();

            builder.Services
            .AddCustomLogging()

            #region DataEnrichment StartUp
            .AddConfigurations <CosmoDBSettings>(configuration, "CosmosReadDb")
            .AddConfigurations <CosmoDBSettings>(configuration, "CosmosWriteDb")
            .AddSingleton <ITableStorageSettings>(x => configuration.GetSection("TableStorageSettings").Get <TableStorageSettings>())
            .AddCustomTableStorage <StoredPersonalInfo>()
            .AddCustomTableStorage <ContextMapping>()
            .AddStorageRepository(configuration)
            .AddSingleton <IRestSharp, RestSharpHelper>()
            .AddSingleton <IEffectiveAuthorizationHandlerFactory>(s =>
            {
                var factory = new EffectiveAuthorizationHandlerFactory();
                factory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler());
                factory.RegisterHandler(typeof(EffectiveAuthorizationRevokedEvent), new PermissionRevokedHandler());
                return(factory);
            })
            .AddScoped <IPersonLocalStorage, PersonLocalStorage>()
            .AddScoped <IContextMappingLocalStorage, ContextMappingLocalStorage>()
            .AddScoped <IEffectiveAuthorizationTimelineFactory, EffectiveAuthorizationTimelineFactory>()
            .AddScoped <IUserInformation, UserInformation>()
            #endregion

            #region GenerateReport StartUp
            .AddSingleton <ITableStorageSettings, TableStorageSettings>(x => configuration.GetSection("TableStorageSettings").Get <TableStorageSettings>())
            .AddSingleton <ICosmoDBSettings, CosmoDBSettings>(x => configuration.GetSection("CosmosWriteDb").Get <CosmoDBSettings>())
            .AddSingleton <IQueueStorageSettings, QueueStorageSettings>(x => configuration.GetSection("QueueStorageSettings").Get <QueueStorageSettings>())
            .AddScoped <IGenerateReportBusiness, GenerateReportBusiness>()
            .AddSingleton <IChecksumGenerator, ChecksumGenerator>()
            .AddScoped <IReportingBusiness, ReportingBusiness>()
            .AddScoped <IAzureQueueStorageInitializer, AzureQueueStorageInitializer>()
            .AddScoped <IAzureQueueStorageRepository, AzureQueueStorageRepository>()
            .AddScoped <IAzureTableStorageRepository <FileInformation>, AzureTableStorageRepository <FileInformation> >()
            #endregion

            #region InitialLoad StartUp
            .AddSingleton <ICosmoDBSettings, CosmoDBSettings>(e => configuration.GetSection("CosmosReadDb").Get <CosmoDBSettings>())
            .AddScoped <IInitialLoadBusiness, InitialLoadBusiness>()
            .AddSingleton <IWriteRawEventStorage, RawEventStorageRepository>()
            #endregion

            #region Shared StartUp
            .AddCustomBlobStorageSettings(configuration)
            .AddSingleton <ICosmoDBStorageInitializer, CosmoDBStorageInitializer>()
            .AddScoped <IAzureBlobStorageInitializer, AzureBlobStorageInitializer>()
            .AddScoped <IAzureBlobStorageRepository, AzureBlobStorageRepository>()
            .AddSingleton <IAzureTableStorageInitializer, AzureTableStorageInitializer>();
            #endregion

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.AddProfile <ExternalIdProfile>();
                cfg.AddProfile <PermissionProfile>();
                cfg.AddProfile <EffectiveAuthorizationProfile>();
                cfg.AddProfile <EffectiveAuthorizationGrantedEventProfile>();
                cfg.AddProfile <EffectiveAuthorizationRevokedEventProfile>();
                cfg.AddProfile <EffectiveIntervalCSVMapperProfile>();
            });
        }