Beispiel #1
0
 public GraceRefreshTokenService(
     IScopedHttpContextRequestForm scopedHttpContextRequestForm,
     IRefreshTokenStore refreshTokenStore,
     IProfileService profile,
     ISystemClock clock,
     ILogger <DefaultRefreshTokenService> logger) :
     base(refreshTokenStore, profile, clock, logger)
 {
     _scopedHttpContextRequestForm = scopedHttpContextRequestForm;
 }
Beispiel #2
0
 public MyDefaultResourceValidator(
     IHttpContextAccessor httpContextAccessor,
     IResourceStore store,
     IScopeParser scopeParser,
     IScopedHttpContextRequestForm scopedHttpContextRequestForm,
     ILogger <DefaultResourceValidator> logger) : base(store, scopeParser, logger)
 {
     _httpContextAccessor          = httpContextAccessor;
     _scopedHttpContextRequestForm = scopedHttpContextRequestForm;
     _logger      = logger;
     _scopeParser = scopeParser;
 }
 public EntityFrameworkPersistedGrantStoreEx(
     IScopedHttpContextRequestForm scopedHttpContextRequestForm,
     IScopedContext <TenantRequestContext> scopedTenantRequestContext,
     IScopedStorage scopedStorage,
     IAdminServices adminServices,
     IEntityFrameworkMapperAccessor entityFrameworkMapperAccessor,
     ITenantAwareConfigurationDbContextAccessor tenantAwareConfigurationDbContextAccessor,
     ILogger <EntityFrameworkPersistedGrantStoreEx> logger)
 {
     _scopedHttpContextRequestForm = scopedHttpContextRequestForm;
     _scopedTenantRequestContext   = scopedTenantRequestContext;
     _scopedStorage = scopedStorage;
     _adminServices = adminServices;
     _entityFrameworkMapperAccessor             = entityFrameworkMapperAccessor;
     _tenantAwareConfigurationDbContextAccessor = tenantAwareConfigurationDbContextAccessor;
     Logger = logger;
 }
Beispiel #4
0
 public MyTokenResponseGenerator(
     IScopedHttpContextRequestForm scopedHttpContextRequestForm,
     IHttpContextAccessor contextAccessor,
     IScopedOptionalClaims scopedOptionalClaims,
     IScopedStorage scopedStorage,
     IRefreshTokenStore refreshTokenStore,
     IReferenceTokenStore referenceTokenStore,
     IPersistedGrantStoreEx persistedGrantStore,
     ISystemClock clock,
     ITokenService tokenService,
     IRefreshTokenService refreshTokenService,
     IScopeParser scopeParser,
     IResourceStore resources,
     IClientStore clients,
     ILogger <TokenResponseGenerator> logger) : base(clock, tokenService, refreshTokenService, scopeParser, resources, clients, logger)
 {
     _scopedHttpContextRequestForm = scopedHttpContextRequestForm;
     _contextAccessor      = contextAccessor;
     _scopedOptionalClaims = scopedOptionalClaims;
     _refreshTokenStore    = refreshTokenStore;
     _referenceTokenStore  = referenceTokenStore;
     _scopedStorage        = scopedStorage;
     _persistedGrantStore  = persistedGrantStore;
 }
Beispiel #5
0
        public async Task Invoke(HttpContext context,
                                 IScopedContext <TenantRequestContext> scopedTenantRequestContext,
                                 IScopedHttpContextRequestForm scopedHttpContextRequestForm,
                                 ITenantStore tenantStore)
        {
            try
            {
                // TODO: Probably should use regex here.
                string[] parts = context.Request.Path.Value.Split('/');
                if (parts.Count() > 1)
                {
                    string tenantName = parts[1];
                    scopedTenantRequestContext.Context.TenantName = tenantName;
                    if (string.IsNullOrWhiteSpace(tenantName) || !await tenantStore.IsTenantValidAsync(tenantName))
                    {
                        _logger.LogWarning($"TenantId={tenantName}, does not exist!");
                        context.Response.Clear();
                        context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                        await context.Response.WriteAsync("");

                        return;
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.Append('/');
                    if (parts.Count() > 2)
                    {
                        for (int i = 2; i < parts.Count(); i++)
                        {
                            sb.Append(parts[i]);
                            if (i < parts.Count() - 1)
                            {
                                sb.Append('/');
                            }
                        }
                    }
                    string newPath = sb.ToString();
                    context.Request.Path     = newPath;
                    context.Request.PathBase = $"/{tenantName}";

                    switch (context.Request.Method)
                    {
                    case "GET":
                        break;

                    case "POST":
                        if (context.Request.ContentType == "application/x-www-form-urlencoded")
                        {
                            scopedTenantRequestContext.Context.FormCollection = await scopedHttpContextRequestForm.GetFormCollectionAsync();
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex, "Unhandled exception: {exception}", ex.Message);
                throw;
            }

            await _next(context);
        }