Exemplo n.º 1
0
        public async Task StoreAsync(PersistedGrant token)
        {
            var site = _contextAccessor.HttpContext.GetTenant<SiteContext>();
            if (site == null)
            {
                _logger.LogError("sitecontext was null");
                return;
            }
            var _siteId = site.Id.ToString();

            var existing = await _context.PersistedGrants.SingleOrDefaultAsync(x => x.SiteId == _siteId && x.Key == token.Key)
                .ConfigureAwait(false);
            if (existing == null)
            {
                var persistedGrant = token.ToEntity();
                persistedGrant.SiteId = _siteId;
                _context.PersistedGrants.Add(persistedGrant);
            }
            else
            {
                token.UpdateEntity(existing);
            }

            try
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.LogError(0, ex, "StoreAsync");
            }  
        }
Exemplo n.º 2
0
        public GrantItem(PersistedGrant grant) : base()
        {
            this.Id = Guid.NewGuid().ToString();
            this.ClientId = grant.ClientId;
            this.CreationTime = grant.CreationTime;
            this.Data = grant.Data;
            this.Expiration = grant.Expiration;
            this.Key = grant.Key;
            this.SubjectId = grant.SubjectId;
            this.Type = grant.Type;

        }
Exemplo n.º 3
0
        public async Task StoreAsync(PersistedGrant token)
        {
            try
            {
                var site = _contextAccessor.HttpContext.GetTenant<SiteContext>();
                if(site == null)
                {
                    _logger.LogError("sitecontext was null");
                    return;
                }
                var grant = new GrantItem(token);
                await RemoveAsync(grant.Key).ConfigureAwait(false);
                await _commands.CreateAsync(site.Id.ToString(), grant.Id, grant).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.LogError(0, ex, "StoreAsync");
            }

            
        }
Exemplo n.º 4
0
 public static UserGrant ToGrant(this PersistedGrant model, UserGrant userGrant = null)
 {
     return(GetInstance().Map(model, userGrant));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Maps an entity to a model.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <returns></returns>
 public static IdentityServer4.Models.PersistedGrant ToModel(this PersistedGrant entity)
 {
     return(entity == null ? null : Mapper.Map <IdentityServer4.Models.PersistedGrant>(entity));
 }
 public static PersistedGrantDto ToModel(this PersistedGrant grant)
 {
     return(grant == null ? null : Mapper.Map <PersistedGrantDto>(grant));
 }
        /// <summary>
        /// Stores the grant.
        /// </summary>
        /// <param name="grant">The grant.</param>
        /// <returns></returns>
        public Task StoreAsync(PersistedGrant grant)
        {
            _repository[grant.Key] = grant;

            return(Task.FromResult(0));
        }
 /// <summary>
 /// Maps a model to an entity.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns></returns>
 public static Entities.PersistedGrant ToEntity(this PersistedGrant model)
 {
     return(model == null ? null : Mapper.Map <Entities.PersistedGrant>(model));
 }
Exemplo n.º 9
0
 public Task StoreAsync(PersistedGrant grant)
 {
     return(_inMemoryPersistedGrantStore.StoreAsync(grant));
 }
 public async Task Add(PersistedGrant entity)
 {
     _persistedGrants.Insert(entity);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Stores the grant.
        /// </summary>
        /// <param name="grant">The grant.</param>
        /// <returns></returns>
        public Task StoreAsync(PersistedGrant grant)
        {
            _repository[grant.Key] = grant;

            return(Task.CompletedTask);
        }
Exemplo n.º 12
0
 public Task StoreAsync(PersistedGrant grant)
 {
     return(_repository.AddAsync(grant));
 }
 public async Task StoreAsync(PersistedGrant pGrant)
 {
     var grant = ToGrant(pGrant);
     await _grantRepository.SaveAsync(grant);
 }
 public PersistedGrantDocument(PersistedGrant grant) : base(grant)
 {
     Id = GuidGenerator.CreateGuid(grant.Key).ToString();
 }
Exemplo n.º 15
0
        public async Task StoreAsync(PersistedGrant grant)
        {
            await RemoveAsync(grant.Key);

            _persistedGrants.Add(grant);
        }
Exemplo n.º 16
0
 private static string ConvertToJson(PersistedGrant grant)
 {
     return(JsonConvert.SerializeObject(grant));
 }
Exemplo n.º 17
0
 public Task SavePersistedGrant(PersistedGrant persistedGrant)
 {
     throw new System.NotImplementedException();
 }
 public static Entity.PersistedGrants ToEntity(this PersistedGrant model)
 {
     return(Mapper.Map <Entity.PersistedGrants>(model));
 }
Exemplo n.º 19
0
 public Task StoreAsync(PersistedGrant grant)
 {
     throw new NotImplementedException();
 }
 private void UpdateEntity(Grant entity, PersistedGrant model)
 {
     Mapper.Map(model, entity);
 }
Exemplo n.º 21
0
 public Task Store(PersistedGrant grant)
 {
     _data.State.Grant = grant;
     return(_data.WriteStateAsync());
 }
 public async Task Update(Expression <Func <PersistedGrant, bool> > filter, PersistedGrant entity)
 {
     _persistedGrants.Upsert(entity);
 }
Exemplo n.º 23
0
 public Task StoreAsync(PersistedGrant grant)
 {
     this.repository.Add <PersistedGrant>(grant);
     return(Task.CompletedTask);
 }
 async Task StoreAsync(PersistedGrant persistedGrant)
 {
     await _persistedGrantStore.StoreAsync(persistedGrant);
 }
Exemplo n.º 25
0
 public Task StoreAsync(PersistedGrant grant)
 {
     _dbRepository.Add <PersistedGrant>(grant);
     return(Task.FromResult(0));
 }
Exemplo n.º 26
0
 public Task StoreAsync(PersistedGrant grant)
 {
     return(_client.GetGrain <IGrantGrain>(grant.Key).Store(grant));
 }
 /// <summary>
 /// Updates an entity from a model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="entity">The entity.</param>
 public static void UpdateEntity(this PersistedGrant model, XpoPersistedGrant entity)
 => Mapper.Map(model, entity);
 /// <summary>
 /// Updates an entity from a model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="entity">The entity.</param>
 public static void UpdateEntity(this PersistedGrant model, Entities.PersistedGrant entity)
 {
     Mapper.Map(model, entity);
 }
Exemplo n.º 29
0
 public static Entities.PersistedGrant ToEntity(this PersistedGrant token)
 {
     return(token == null ? null : Mapper.Map <Entities.PersistedGrant>(token));
 }
Exemplo n.º 30
0
 /// <summary>
 /// Updates an entity from a model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="entity">The entity.</param>
 public static void UpdateEntity(this IdentityServer4.Models.PersistedGrant model, PersistedGrant entity)
 {
     Mapper.Map(model, entity);
 }
Exemplo n.º 31
0
 public static void UpdateEntity(this PersistedGrant token, Entities.PersistedGrant target)
 {
     Mapper.Map(token, target);
 }
Exemplo n.º 32
0
 public async override Task StoreAsync(PersistedGrant grant)
 {
     await _grants.InsertOneAsync(grant);
 }
Exemplo n.º 33
0
 public static PersistedGrant ToPersistanceGrant(this UserGrant userGrant, PersistedGrant model = null)
 {
     return(GetInstance().Map(userGrant, model));
 }