Skip to content

Commit

Permalink
fix: Allow to pass non-compliant passwords in the Authorization header
Browse files Browse the repository at this point in the history
  • Loading branch information
angelobreuer committed Mar 4, 2024
1 parent 5797282 commit edd964e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Lavalink4NET.Rest/LavalinkApiClientBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace Lavalink4NET.Rest;

using System.Net.Http;
using System.Net.Http.Headers;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

Expand All @@ -12,7 +11,7 @@ public abstract class LavalinkApiClientBase
private readonly IOptions<LavalinkApiClientOptions> _options;
private readonly ILogger<LavalinkApiClientBase> _logger;
private readonly IHttpClientFactory _httpClientFactory;
private readonly AuthenticationHeaderValue _authenticationHeaderValue;
private readonly string _authenticationHeaderValue;

protected LavalinkApiClientBase(
IHttpClientFactory httpClientFactory,
Expand All @@ -31,13 +30,13 @@ protected LavalinkApiClientBase(
_options = options;
_logger = logger;
_httpClientFactory = httpClientFactory;
_authenticationHeaderValue = new AuthenticationHeaderValue(options.Value.Passphrase);
_authenticationHeaderValue = options.Value.Passphrase;
}

public HttpClient CreateHttpClient()
{
var httpClient = _httpClientFactory.CreateClient(_options.Value.HttpClientName);
httpClient.DefaultRequestHeaders.Authorization = _authenticationHeaderValue;
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", _authenticationHeaderValue);
return httpClient;
}
}

0 comments on commit edd964e

Please sign in to comment.