private async Task AddPersistedGrants()
        {
            await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
            {
                Key       = "PersistedGrantKey1",
                SubjectId = "PersistedGrantSubjectId1",
                SessionId = "PersistedGrantSessionId1",
                ClientId  = "PersistedGrantClientId1",
                Type      = "PersistedGrantType1",
                Data      = ""
            });

            await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
            {
                Key       = "PersistedGrantKey2",
                SubjectId = "PersistedGrantSubjectId2",
                ClientId  = "c1",
                Type      = "c1type",
                Data      = ""
            });

            await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
            {
                Key        = "PersistedGrantKey3",
                SubjectId  = "PersistedGrantSubjectId3",
                ClientId   = "c1",
                Type       = "c1type",
                Data       = "",
                Expiration = _clock.Now.AddDays(1),
            });

            await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
            {
                Key        = "PersistedGrantKey_Expired1",
                SubjectId  = "PersistedGrantSubjectId_Expired1",
                ClientId   = "c1",
                Type       = "c1type",
                Data       = "",
                Expiration = _clock.Now.AddDays(-1)
            });
        }
        private async Task AddPersistentGrants()
        {
            await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
            {
                Key       = "38",
                ClientId  = "TestClientId-38",
                Type      = "TestType-38",
                SubjectId = "TestSubject",
                Data      = "TestData-38"
            });

            await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
            {
                Key       = "37",
                ClientId  = "TestClientId-37",
                Type      = "TestType-37",
                SubjectId = "TestSubject",
                Data      = "TestData-37"
            });

            await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
            {
                Key       = "36",
                ClientId  = "TestClientId-X",
                Type      = "TestType-36",
                SubjectId = "TestSubject-X",
                Data      = "TestData-36"
            });

            await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
            {
                Key       = "35",
                ClientId  = "TestClientId-X",
                Type      = "TestType-35",
                SubjectId = "TestSubject-X",
                Data      = "TestData-35"
            });
        }
Exemplo n.º 3
0
        public virtual async Task StoreAsync(IdentityServer4.Models.PersistedGrant grant)
        {
            var entity   = _objectMapper.Map <IdentityServer4.Models.PersistedGrant, PersistedGrant>(grant);
            var existing = await _persistentGrantRepository.FindByKeyAsync(grant.Key);

            if (existing == null)
            {
                entity.Id = _guidGenerator.Create();
                await _persistentGrantRepository.InsertAsync(entity);
            }
            else
            {
                await _persistentGrantRepository.UpdateAsync(entity);
            }
        }
Exemplo n.º 4
0
        public virtual async Task StoreAsync(IdentityServer4.Models.PersistedGrant grant)
        {
            var entity = await _persistentGrantRepository.FindByKeyAsync(grant.Key);

            if (entity == null)
            {
                entity = _objectMapper.Map <IdentityServer4.Models.PersistedGrant, PersistedGrant>(grant);
                EntityHelper.TrySetId(entity, () => _guidGenerator.Create());
                await _persistentGrantRepository.InsertAsync(entity);
            }
            else
            {
                _objectMapper.Map(grant, entity);
                await _persistentGrantRepository.UpdateAsync(entity);
            }
        }