public override async Task <bool> CanProvideCredentialsAsync(Uri uri)
        {
            // If for any reason we reach this point and any of the three build task env vars are set,
            // we should not try get credentials with this cred provider.
            string feedEndPointsJsonEnvVar = Environment.GetEnvironmentVariable(EnvUtil.BuildTaskExternalEndpoints);
            string uriPrefixesStringEnvVar = Environment.GetEnvironmentVariable(EnvUtil.BuildTaskUriPrefixes);
            string accessTokenEnvVar       = Environment.GetEnvironmentVariable(EnvUtil.BuildTaskAccessToken);

            if (string.IsNullOrWhiteSpace(feedEndPointsJsonEnvVar) == false || string.IsNullOrWhiteSpace(uriPrefixesStringEnvVar) == false || string.IsNullOrWhiteSpace(accessTokenEnvVar) == false)
            {
                Verbose(Resources.BuildTaskCredProviderIsUsedError);
                return(false);
            }

            var validHosts = EnvUtil.GetHostsFromEnvironment(Logger, EnvUtil.SupportedHostsEnvVar, new[]
            {
                ".pkgs.vsts.me",          // DevFabric
                ".pkgs.codedev.ms",       // DevFabric
                ".pkgs.codeapp.ms",       // AppFabric
                ".pkgs.visualstudio.com", // Prod
                ".pkgs.dev.azure.com"     // Prod
            });

            return(validHosts.Any(host => uri.Host.EndsWith(host, StringComparison.OrdinalIgnoreCase)) || await authUtil.IsVstsUriAsync(uri));
        }
        private bool UsePpeAadUrl(Uri uri)
        {
            var ppeHosts = EnvUtil.GetHostsFromEnvironment(logger, EnvUtil.PpeHostsEnvVar, new[]
            {
                ".vsts.me",
                ".codedev.ms",
                ".devppe.azure.com"
            });

            return(ppeHosts.Any(host => uri.Host.EndsWith(host, StringComparison.OrdinalIgnoreCase)));
        }
Beispiel #3
0
        public override async Task <bool> CanProvideCredentialsAsync(Uri uri)
        {
            var validHosts = EnvUtil.GetHostsFromEnvironment(Logger, EnvUtil.SupportedHostsEnvVar, new[]
            {
                ".pkgs.vsts.me",          // DevFabric
                ".pkgs.codedev.ms",       // DevFabric
                ".pkgs.codeapp.ms",       // AppFabric
                ".pkgs.visualstudio.com", // Prod
                ".pkgs.dev.azure.com"     // Prod
            });

            return(validHosts.Any(host => uri.Host.EndsWith(host, StringComparison.OrdinalIgnoreCase)) || await authUtil.IsVstsUriAsync(uri));
        }