mikefourie-zz / MSBuildExtensionPack

MIT License
366 stars 104 forks source link

Explicit Http Credentials for HttpWebRequest? #34

Closed wbradney closed 6 years ago

wbradney commented 9 years ago

What do people think about adding parameters for explicit username and password? I have a scenario (TeamCity) where I need to make a REST-ful POST request from the build, but the server only supports basic HTTP authentication, so I would need to provide a NetworkCredential with a specific user name and password. I know having passwords in the build file would be considered less than ideal, but in my case TeamCity actually provides build properties for the server's credentials that I would use, so I wouldn't need to have a clear text password anyway in my case.

kevindaub commented 9 years ago

There's other places where passwords are provided in MSBuildExtensionPack, so I think it's reasonable. I think it's really up to the consumer to determine how they wish to secure the password not the framework.

I hope that the basic authentication is at least over SSL.

mikefourie-zz commented 6 years ago

I think this is alreadysupported. Just pass in U/P

if (this.UseIntegratedAuthentication) { request.Credentials = CredentialCache.DefaultCredentials; } else if (!string.IsNullOrEmpty(this.UserName)) { request.Credentials = new System.Net.NetworkCredential(this.UserName, this.UserPassword); }