コード例 #1
0
        private ConfigurationValidationResult CheckForUnsupportedAuthenticationProviders(FileConfiguration configuration)
        {
            var errors = new List <Error>();

            foreach (var reRoute in configuration.ReRoutes)
            {
                var isAuthenticated = !string.IsNullOrEmpty(reRoute.AuthenticationOptions?.Provider);

                if (!isAuthenticated)
                {
                    continue;
                }

                if (IsSupportedAuthenticationProvider(reRoute.AuthenticationOptions?.Provider))
                {
                    continue;
                }

                var error = new UnsupportedAuthenticationProviderError($"{reRoute.AuthenticationOptions?.Provider} is unsupported authentication provider, upstream template is {reRoute.UpstreamPathTemplate}, upstream method is {reRoute.UpstreamHttpMethod}");
                errors.Add(error);
            }

            return(errors.Count > 0
                ? new ConfigurationValidationResult(true, errors)
                : new ConfigurationValidationResult(false));
        }
コード例 #2
0
        private async Task <ConfigurationValidationResult> CheckForUnsupportedAuthenticationProviders(FileConfiguration configuration)
        {
            var errors = new List <Error>();

            foreach (var reRoute in configuration.ReRoutes)
            {
                var isAuthenticated = !string.IsNullOrEmpty(reRoute.AuthenticationOptions.AuthenticationProviderKey);

                if (!isAuthenticated)
                {
                    continue;
                }

                var data = await _provider.GetAllSchemesAsync();

                var schemes = data.ToList();
                if (schemes.Any(x => x.Name == reRoute.AuthenticationOptions.AuthenticationProviderKey))
                {
                    continue;
                }

                var error = new UnsupportedAuthenticationProviderError($"{reRoute.AuthenticationOptions.AuthenticationProviderKey} is unsupported authentication provider, upstream template is {reRoute.UpstreamPathTemplate}, upstream method is {reRoute.UpstreamHttpMethod}");
                errors.Add(error);
            }

            return(errors.Count > 0
                ? new ConfigurationValidationResult(true, errors)
                : new ConfigurationValidationResult(false));
        }