private async Task AddIdentityResources()
    {
        var identityResource1 = new IdentityResource(_testData.IdentityResource1Id, "NewIdentityResource1")
        {
            Description = nameof(Client.Description),
            DisplayName = nameof(IdentityResource.DisplayName)
        };

        identityResource1.AddUserClaim(nameof(ApiResourceClaim.Type));

        await _identityResourceRepository.InsertAsync(identityResource1);

        await _identityResourceRepository.InsertAsync(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource2"));

        await _identityResourceRepository.InsertAsync(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource3"));

        var identityResource2 = new IdentityResource(_guidGenerator.Create(), "Test-Identity-Resource-Name-1")
        {
            Description = "Test-Identity-Resource-Description-1",
            DisplayName = "Test-Identity-Resource-DisplayName-1",
            Required    = true,
            Emphasize   = true
        };

        identityResource2.AddUserClaim("Test-Identity-Resource-1-IdentityClaim-Type-1");
        await _identityResourceRepository.InsertAsync(identityResource2);
    }
Ejemplo n.º 2
0
        private async Task AddIdentityResources()
        {
            var identityResource = new IdentityResource(_testData.IdentityResource1Id, "NewIdentityResource1")
            {
                Description = nameof(Client.Description),
                DisplayName = nameof(IdentityResource.DisplayName)
            };

            identityResource.AddUserClaim(nameof(ApiResourceClaim.Type));

            await _identityResourceRepository.InsertAsync(identityResource).ConfigureAwait(false);

            await _identityResourceRepository.InsertAsync(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource2")).ConfigureAwait(false);

            await _identityResourceRepository.InsertAsync(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource3")).ConfigureAwait(false);
        }
Ejemplo n.º 3
0
        private async Task SaveIdentityResourcesAsync()
        {
            var identityResourceOpenId = new IdentityResource(Guid.NewGuid(), "openid", "OpenID", required: true);
            await _identityResourceRepository.InsertAsync(identityResourceOpenId);

            var identityResourceEmail = new IdentityResource(Guid.NewGuid(), "email", "Email", required: true);

            identityResourceEmail.AddUserClaim("email");
            identityResourceEmail.AddUserClaim("email_verified");
            await _identityResourceRepository.InsertAsync(identityResourceEmail);

            var identityResourceRole = new IdentityResource(Guid.NewGuid(), "roles", "Roles", required: true);

            identityResourceRole.AddUserClaim("role");
            await _identityResourceRepository.InsertAsync(identityResourceRole);

            var identityResourceProfile = new IdentityResource(Guid.NewGuid(), "profile", "Profile", required: true);

            identityResourceProfile.AddUserClaim("unique_name");
            await _identityResourceRepository.InsertAsync(identityResourceProfile);
        }
Ejemplo n.º 4
0
        public async Task CreateIdentityResourcesAsync(string name, IEnumerable <string> claims)
        {
            var identityResource = new IdentityResource(guidGenerator.Create(), name, $"{name} Identity", required: true);

            foreach (var claim in claims)
            {
                if (identityResource.FindUserClaim(claim) == null)
                {
                    identityResource.AddUserClaim(claim);
                }
            }

            await identityResourceRepository.InsertAsync(identityResource);
        }
        private async Task AddIdentityResources()
        {
            var identityResource = new IdentityResource(_guidGenerator.Create(), "Test-Identity-Resource-Name-1")
            {
                Description = "Test-Identity-Resource-Description-1",
                DisplayName = "Test-Identity-Resource-DisplayName-1",
                Required    = true,
                Emphasize   = true
            };

            identityResource.AddUserClaim("Test-Identity-Resource-1-IdentityClaim-Type-1");

            await _identityResourceRepository.InsertAsync(identityResource);
        }
Ejemplo n.º 6
0
        public virtual async Task <IdentityResourceDto> CreateAsync(IdentityResourceCreateUpdateDto input)
        {
            var existed = await _resourceRepository.CheckNameExistAsync(input.Name);

            if (existed)
            {
                throw new UserFriendlyException(L["EntityExisted", nameof(IdentityResource),
                                                  nameof(IdentityResource.Name),
                                                  input.Name]);
            }

            var identityResource = new IdentityResource(GuidGenerator.Create(), input.Name);

            identityResource = ObjectMapper.Map(input, identityResource);
            input.UserClaims.ForEach(x => identityResource.AddUserClaim(x));

            identityResource = await _resourceRepository.InsertAsync(identityResource, true);

            return(ObjectMapper.Map <IdentityResource, IdentityResourceDto>(identityResource));
        }
Ejemplo n.º 7
0
        public async Task <IdentityResourceDto> CreateAsync(CreateIdentityResourceInputDto input)
        {
            var nameExist = await _repository.CheckNameExistAsync(input.Name.Trim());

            if (nameExist)
            {
                throw new IdentityResourceNameNotAllowedDuplicateException(input.Name);
            }
            var identityResource = new IdentityResource(GuidGenerator.Create(), input.Name.Trim())
            {
                DisplayName             = input.DisplayName?.Trim(),
                Description             = input.Description?.Trim(),
                Enabled                 = input.Enabled,
                Required                = input.Required,
                Emphasize               = input.Emphasize,
                ShowInDiscoveryDocument = input.ShowInDiscoveryDocument
            };

            input.UserClaims.ForEach(x => identityResource.AddUserClaim(x));
            identityResource = await _repository.InsertAsync(identityResource);

            return(MapToGetOutputDto(identityResource));
        }
        public async Task <IdentityResourceDto> CreateAsync(CreateIdentityResourceInputDto input)
        {
            var nameExist = await _repository.CheckNameExistAsync(input.Name.Trim());

            if (nameExist)
            {
                throw new IdentityResourceNameNotAllowedDuplicateException(input.Name);
            }
            var identityResource = new IdentityResource(GuidGenerator.Create(), input.Name.Trim())
            {
                DisplayName             = input.DisplayName?.Trim(),
                Description             = input.Description?.Trim(),
                Enabled                 = input.Enabled,
                Required                = input.Required,
                Emphasize               = input.Emphasize,
                ShowInDiscoveryDocument = input.ShowInDiscoveryDocument,
                Properties              = new Dictionary <string, string>()
            };

            input.UserClaims.ForEach(x => identityResource.AddUserClaim(x));

            if (input.Properties != null)
            {
                input.Properties.ForEach(x =>
                {
                    if (!identityResource.Properties.ContainsKey(x.Key))
                    {
                        identityResource.Properties.Add(x.Key, x.Value);
                    }
                });
            }

            identityResource = await _repository.InsertAsync(identityResource);

            return(MapToGetOutputDto(identityResource));
        }
 public async Task <int> InsertIdentityResourceAsync(Core.Entities.IdentityResource.IdentityResource identityResource)
 {
     return(await _repository.InsertAsync(identityResource));
 }