private static Client GetClient(ClientResource resource)
        {
            var client = resource.Spec;

            if (string.IsNullOrEmpty(client.ClientId))
            {
                client.ClientId = resource.Metadata.Namespace + "-" + resource.Metadata.Name;
            }

            return(client);
        }
Esempio n. 2
0
        private static Client EnsureWellFormedAllowedCorsOrigins(ClientResource clientResource, ILogger logger)
        {
            var client = clientResource.Spec;

            if (client.AllowedCorsOrigins.All(IsWellFormedUriString))
            {
                return(client);
            }

            logger.LogWarning($"Identity Client with name {client.ClientName} has invalid AllowedCorsOrigins");

            return(new Client
            {
                ClientName = client.ClientName,
                AllowedCorsOrigins = client.AllowedCorsOrigins.Where(IsWellFormedUriString).ToList()
            });
        }
        public void DetectsEqualClients()
        {
            var client1 = new ClientResource("ns", "client", new Client
            {
                AllowOfflineAccess = true,
                AllowedCorsOrigins =
                {
                    "http://example.com"
                }
            });
            var client2 = new ClientResource("ns", "client", new Client
            {
                AllowOfflineAccess = true,
                AllowedCorsOrigins =
                {
                    "http://example.com"
                }
            });

            client1.Equals(client2).Should().BeTrue();
        }
        private static Client GetClient(ClientResource resource, ILogger logger)
        {
            var client = resource.Spec;

            if (string.IsNullOrEmpty(client.ClientId))
            {
                client.ClientId = resource.Metadata.Namespace + "-" + resource.Metadata.Name;
            }

            if (client.AllowedCorsOrigins.All(IsWellFormedUriString))
            {
                return(client);
            }

            logger.LogWarning($"Identity Client with name {client.ClientName} has invalid AllowedCorsOrigins");

            return(new Client
            {
                ClientName = client.ClientName,
                AllowedCorsOrigins = client.AllowedCorsOrigins.Where(IsWellFormedUriString).ToList()
            });
        }