示例#1
0
        public async Task CreateIdentityResource(string siteId, IdentityResource identityResource, CancellationToken cancellationToken = default(CancellationToken))
        {
            var ent = identityResource.ToEntity();

            ent.SiteId = siteId;

            using (var context = _contextFactory.CreateContext())
            {
                context.IdentityResources.Add(ent);
                await context.SaveChangesAsync();
            }
        }
示例#2
0
        public async Task CreateClient(string siteId, Client client, CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            var ent = client.ToEntity();

            ent.SiteId = siteId;

            using (var context = _contextFactory.CreateContext())
            {
                context.Clients.Add(ent);
                await context.SaveChangesAsync().ConfigureAwait(false);
            }
        }
示例#3
0
        public async Task <IdentityResource> FetchIdentityResource(string siteId, string name, CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (var context = _contextFactory.CreateContext())
            {
                IQueryable <Entities.IdentityResource> query = context.IdentityResources
                                                               .AsNoTracking()
                                                               .Include(x => x.UserClaims);

                query = query.Where(x => x.SiteId == siteId && x.Name == name);
                var ent = await query.SingleOrDefaultAsync();

                return(ent.ToModel());
            }
        }
示例#4
0
        public async Task CreateApiResource(string siteId, ApiResource apiResource, CancellationToken cancellationToken = default(CancellationToken))
        {
            var ent = apiResource.ToEntity();

            ent.SiteId = siteId;
            foreach (var s in ent.Scopes)
            {
                s.SiteId = siteId;
            }

            using (var context = _contextFactory.CreateContext())
            {
                context.ApiResources.Add(ent);
                await context.SaveChangesAsync();
            }
        }
示例#5
0
        public async Task <Client> FetchClient(string siteId, string clientId, CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (var context = _contextFactory.CreateContext())
            {
                var client = await context.Clients
                             .AsNoTracking()
                             .Include(x => x.AllowedGrantTypes)
                             .Include(x => x.RedirectUris)
                             .Include(x => x.PostLogoutRedirectUris)
                             .Include(x => x.AllowedScopes)
                             .Include(x => x.ClientSecrets)
                             .Include(x => x.Claims)
                             .Include(x => x.IdentityProviderRestrictions)
                             .Include(x => x.Properties)
                             .Include(x => x.AllowedCorsOrigins)
                             .FirstOrDefaultAsync(x => x.SiteId == siteId && x.ClientId == clientId);

                var model = client.ToModel();

                return(model);
            }
        }