I`m setting up a new WebAPI server (ASP NET), we're using HTTPS and checking for a valid password, which is passed through the message header.
Server side, I can check if every package is delivered through HTTPS, and if it contains the correct header with password information.
My question is: We're using refit on the API client, inserting the password as a header on every package. Can the client pass the header, or a single message unencrypted?
Here`s the code:
Connection and initialization
var httpClient = new HttpClient(new AuthenticatedHttpClientHandler())
{
BaseAddress = new Uri("https://10.103.208.16:45456/")
};
var nsAPI = RestService.For<Interface1>(httpClient);
Method call:
var sugars = await nsAPI.GetMakeUps();
HttpHandler which inserts the password
class AuthenticatedHttpClientHandler : HttpClientHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
request.Headers.Add("pw", "MY_SECRET_PW");
return await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
}
}
Am I at risk that the password could be sniffed unencrypted? Can I enforce refit to communicate / send packages only through HTTPS connections?