diff --git a/CHANGELOG.md b/CHANGELOG.md index c204393..ff31284 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changes in Medidata.MAuth +## v3.1.1 +- **[Core]** Added `ConfigureAwait(false)` avoiding any possible deadlocks. + ## v3.1.0 - **[Core]** Added a new extension method to the utilities which will authenticate a `HttpRequestMessage` with the provided options. diff --git a/src/Medidata.MAuth.Core/MAuthCoreExtensions.cs b/src/Medidata.MAuth.Core/MAuthCoreExtensions.cs index 86a35fd..270fbad 100644 --- a/src/Medidata.MAuth.Core/MAuthCoreExtensions.cs +++ b/src/Medidata.MAuth.Core/MAuthCoreExtensions.cs @@ -35,7 +35,7 @@ internal static class MAuthCoreExtensions public static async Task CalculatePayload( this HttpRequestMessage request, PrivateKeyAuthenticationInfo authInfo) { - var unsignedData = await request.GetSignature(authInfo); + var unsignedData = await request.GetSignature(authInfo).ConfigureAwait(false); var signer = new Pkcs1Encoding(new RsaEngine()); signer.Init(true, authInfo.PrivateKey.AsCipherParameters()); @@ -77,7 +77,7 @@ public static async Task GetSignature(this HttpRequestMessage request, A { request.Method.Method.ToBytes(), Constants.NewLine, request.RequestUri.AbsolutePath.ToBytes(), Constants.NewLine, - (request.Content != null ? await request.Content.ReadAsByteArrayAsync() : new byte[] { }), + (request.Content != null ? await request.Content.ReadAsByteArrayAsync().ConfigureAwait(false) : new byte[] { }), Constants.NewLine, authInfo.ApplicationUuid.ToHyphenString().ToBytes(), Constants.NewLine, authInfo.SignedTime.ToUnixTimeSeconds().ToString().ToBytes() @@ -127,7 +127,7 @@ public async static Task AddAuthenticationInfo( { var authHeader = $"MWS {authInfo.ApplicationUuid.ToHyphenString()}:" + - $"{await request.CalculatePayload(authInfo)}"; + $"{await request.CalculatePayload(authInfo).ConfigureAwait(false)}"; request.Headers.Add(Constants.MAuthHeaderKey, authHeader); request.Headers.Add(Constants.MAuthTimeHeaderKey, authInfo.SignedTime.ToUnixTimeSeconds().ToString()); @@ -159,7 +159,7 @@ public static Task Sign( /// A Task object which will result the application information when it completes. public async static Task FromResponse(this HttpContent content) { - var jsonObject = JObject.Parse(await content.ReadAsStringAsync()); + var jsonObject = JObject.Parse(await content.ReadAsStringAsync().ConfigureAwait(false)); return jsonObject.GetValue("security_token").ToObject(); } diff --git a/src/Medidata.MAuth.Core/MAuthSigningHandler.cs b/src/Medidata.MAuth.Core/MAuthSigningHandler.cs index 4492b01..cc944b2 100644 --- a/src/Medidata.MAuth.Core/MAuthSigningHandler.cs +++ b/src/Medidata.MAuth.Core/MAuthSigningHandler.cs @@ -54,7 +54,7 @@ protected async override Task SendAsync( InnerHandler = new HttpClientHandler(); return await base - .SendAsync(await request.Sign(options), cancellationToken) + .SendAsync(await request.Sign(options).ConfigureAwait(false), cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); } } diff --git a/version.props b/version.props index 9a8155d..78afc83 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 3.1.0 + 3.1.1