Example #1
0
 public ApplicationDbContext(
     DbContextOptions <ApplicationDbContext> options,
     ITenancyContext <ApplicationTenant> tenancyContext)
     : base(options)
 {
     _tenancyContext = tenancyContext;
 }
Example #2
0
 public ApplicationUserClaimsPrincipalFactory(ApplicationUserManager userManager,
                                              IOptions <IdentityOptions> optionsAccessor, ITenancyContext <Tenant> tenancyContext, IHttpContextAccessor httpContext)
     : base(userManager, optionsAccessor)
 {
     _tenancyContext = tenancyContext;
     _httpContext    = httpContext;
     _userManager    = userManager;
 }
Example #3
0
 public ProfileService(IHttpContextAccessor context, UserManager <ApplicationUser> userManager,
                       ApplicationUserClaimsPrincipalFactory claimsFactory, ITenancyContext <Tenant> tenancyContext,
                       ILogger <DefaultProfileService> logger, IResourceStore resourceStore)
 {
     _context        = context;
     _userManager    = userManager;
     _claimsFactory  = claimsFactory;
     _tenancyContext = tenancyContext;
     _logger         = logger;
     _resourceStore  = resourceStore;
 }
 public ApplicationDbContext(
     DbContextOptions <ApplicationDbContext> options,
     ITenancyContext <ApplicationTenant> tenancyContext,
     ILogger <ApplicationDbContext> logger)
     : base(options)
 {
     // The request scoped tenancy context.
     // Should not access the tenancyContext.Tenant property in the constructor yet,
     // as the request pipeline has not finished running yet and it will likely be null.
     // Use the private property wrapper above to access it later on demand.
     _tenancyContext = tenancyContext;
     _logger         = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Example #5
0
 public ManifestCreationStrategyConsideringStateCookieTenantAndTime(
     IFeatureSettingService <TFeatureEnum, TTenantEnum, Tuple <FeatureVisibilityMode, TTenantEnum, DateTime> > featureSettingService,
     IFeatureSettingRepository <TFeatureEnum, TTenantEnum> featureSettingsRepository,
     HttpContextBase httpContext,
     ITenancyContext <TTenantEnum> tenancyContext,
     IApplicationClock clock)
 {
     _featureSettingService     = featureSettingService;
     _featureSettingsRepository = featureSettingsRepository;
     _httpContext    = httpContext;
     _tenancyContext = tenancyContext;
     _clock          = clock;
 }
Example #6
0
        public ApplicationDbContext(
            DbContextOptions <ApplicationDbContext> options,
            ConfigurationStoreOptions storeOptions,
            OperationalStoreOptions operationalOptions,
            ILogger <ApplicationDbContext> logger,
            ITenancyContext <Tenant> tenancyContext = null)
            : base(options)
        {
            _storeOptions       = storeOptions;
            _operationalOptions = operationalOptions;

            _tenancyContext = tenancyContext;
            _logger         = logger;
        }
        public async Task InvokeAsync(
            HttpContext httpContext, ITenancyContext <TTenant, TKey> tenancyContext, ITenancyProvider <TTenant, TKey> tenancyProvider, ITenantStore <TTenant, TKey> tenantStore)
        {
            var tenant = await tenancyProvider.GetCurrentTenantAsync(httpContext.RequestAborted).ConfigureAwait(false);

            if (_logger.IsEnabled(LogLevel.Information))
            {
                if (tenant != null)
                {
                    var tenantId = await tenantStore.GetTenantIdAsync(tenant, httpContext.RequestAborted).ConfigureAwait(false);

                    var canonicalName = await tenantStore.GetCanonicalNameAsync(tenant, httpContext.RequestAborted).ConfigureAwait(false);

                    _logger.LogInformation("Tenant {TenantId} with canonical name {CanonicalName} was found for request {RequestUrl}.",
                                           tenantId, canonicalName, httpContext.Request.GetDisplayUrl());
                }
                else
                {
                    _logger.LogInformation("No tenant was found for request {RequestUrl}.", httpContext.Request.GetDisplayUrl());
                }
            }

            if (!httpContext.Items.ContainsKey(GlobalConst.HttpContextTenancyContext))
            {
                tenancyContext.Tenant = tenant;
                httpContext.Items.Add(GlobalConst.HttpContextTenancyContext, tenancyContext);
            }
            else
            {
                httpContext.Items.TryGetValue(GlobalConst.HttpContextTenancyContext, out var currentTenancyContext);
                if (currentTenancyContext is ITenancyContext <TTenant, TKey> iTenancyContext)
                {
                    iTenancyContext.Tenant = tenant;
                }
            }

            await _next(httpContext).ConfigureAwait(false);
        }
        public async Task InvokeAsync(HttpContext httpContext, ITenancyContext <TTenant> tenancyContext, ITenancyProvider <TTenant> tenancyProvider, ITenantStore <TTenant> tenantStore)
        {
            var tenant = await tenancyProvider.GetCurrentTenantAsync(httpContext.RequestAborted).ConfigureAwait(false);

            if (_logger.IsEnabled(LogLevel.Information))
            {
                if (tenant != null)
                {
                    var tenantId = await tenantStore.GetTenantIdAsync(tenant, httpContext.RequestAborted).ConfigureAwait(false);

                    var canonicalName = await tenantStore.GetCanonicalNameAsync(tenant, httpContext.RequestAborted).ConfigureAwait(false);

                    _logger.LogInformation("Tenant {TenantId} with canonical name {CanonicalName} was found for request {RequestUrl}.",
                                           tenantId, canonicalName, httpContext.Request.GetDisplayUrl());
                }
                else
                {
                    _logger.LogInformation("No tenant was found for request {RequestUrl}.", httpContext.Request.GetDisplayUrl());
                }
            }

            tenancyContext.Tenant = tenant;
            await _next(httpContext).ConfigureAwait(false);
        }
 public ApplicationDbContextConfigurator(ITenancyContext <ApplicationTenant, string> tenancyContext)
 {
     _tenancyContext = tenancyContext;
 }
Example #10
0
 public IndexModel(ILogger <IndexModel> logger, ITenancyContext <ApplicationTenant> tenancyContext)
 {
     _logger         = logger;
     _tenancyContext = tenancyContext;
 }