Ejemplo n.º 1
0
        public async Task <bool> CreateHybridClientIfNotExists(string id, string name, string secret)
        {
            var exists = await _securityRepository.Exists <Client>(c => c.ClientId == id);

            if (exists)
            {
                Log(true, nameof(Client), id);
            }
            else
            {
                Log(false, nameof(Client), id);
                var client = CreateClient(id, name, Flows.Hybrid);
                await _securityRepository.AddClient(client);

                var clientScopes = IdentityScopes.Select(CreateClientScope);
                foreach (var clientScope in clientScopes)
                {
                    clientScope.Client = client;
                    await _securityRepository.AddClientScope(clientScope);
                }

                var clientSecret = CreateClientSecret(secret);
                clientSecret.Client = client;
                await _securityRepository.AddClientSecret(clientSecret);
            }

            return(true);
        }