private async Task <List <AuthorizationPolicyInfo> > GetAll(
            string tenantId,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            var list = _cache.GetAll(tenantId);

            if (list != null)
            {
                return(list);
            }

            using (var db = _contextFactory.CreateContext())
            {
                var all = db.Policies
                          .AsNoTracking()
                          .Include(p => p.AllowedRoles)
                          .Include(p => p.AuthenticationSchemes)
                          .Include(p => p.RequiredClaims)
                          .ThenInclude(x => x.AllowedValues)
                          .Where(p => p.TenantId == tenantId)
                ;

                list = await all.Select(x => x.ToAuthorizationPolicyInfo()).ToListAsync().ConfigureAwait(false);

                if (list.Count > 0)
                {
                    _cache.AddToCache(list, tenantId);
                }

                return(list);
            }
        }
Exemple #2
0
        private async Task <List <AuthorizationPolicyInfo> > GetAll(
            string tenantId,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            var list = _cache.GetAll(tenantId);

            if (list != null)
            {
                return(list);
            }

            var l = await _policyQueries.GetAllAsync(tenantId, cancellationToken).ConfigureAwait(false);

            list = l.ToList();

            if (list.Count > 0)
            {
                _cache.AddToCache(list, tenantId);
            }


            return(list);
        }