-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Describe the bug
After upgrading from version 109.1 to 110.0 I noticed some of our logic is broken.
A typical use case for us is to add security headers during the authentication flow.
public override ValueTask Authenticate(IRestClient client, RestRequest request)
{
request.AddOrUpdateParameter("X-Security-Param", "generated-security-hash");
return ValueTask.CompletedTask;
}However, it doesn't work when sending requests with form data.
While investigating, I found that now when building RequestContent
| using var requestContent = new RequestContent(this, request); |
for
HttpRequestMessage it adds only cached params| var postParameters = _parameters.GetContentParameters(_request.Method).ToArray(); |
but not ones added by Authenticator
| if (authenticator != null) await authenticator.Authenticate(this, request).ConfigureAwait(false); |
To Reproduce
public class RestWrapper : IAuthenticator
{
private readonly RestClient _restClient;
public RestWrapper()
{
_restClient = new RestClient(new RestClientOptions
{
BaseUrl = new Uri("https://localhost"),
Authenticator = this
});
}
public ValueTask Authenticate(IRestClient client, RestRequest request)
{
request.AddParameter("X-Security-Param", "generated-security-hash");
return ValueTask.CompletedTask;
}
public void SendRequest()
{
var testRequest = new RestRequest("api/v1/endpoint", Method.Post);
testRequest.AddParameter("scope", "test");
_restClient.Execute(testRequest);
}
}
new RestWrapper().SendRequest() // server failure - missing X-Security-Param