Skip to content

Commit f6c7cbe

Browse files
committed
Add managed Sigv4a signer.
1 parent 9b002cd commit f6c7cbe

File tree

9 files changed

+615
-57
lines changed

9 files changed

+615
-57
lines changed

sdk/src/Core/Amazon.Runtime/Credentials/Internal/AwsV4aAuthScheme.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public ISigner Signer()
3939
{
4040
if (_signer == null)
4141
{
42-
Interlocked.Exchange(ref _signer, new AWS4aSignerCRTWrapper());
42+
Interlocked.Exchange(ref _signer, new AWS4aSigner());
4343
}
4444

4545
return _signer;

sdk/src/Core/Amazon.Runtime/Internal/Auth/AWS4Signer.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
@@ -31,7 +31,6 @@ namespace Amazon.Runtime.Internal.Auth
3131
/// </summary>
3232
public class AWS4Signer : AbstractAWSSigner
3333
{
34-
3534
public const string Scheme = "AWS4";
3635
public const string Algorithm = "HMAC-SHA256";
3736
public const string Sigv4aAlgorithm = "ECDSA-P256-SHA256";
@@ -299,7 +298,7 @@ private static void CleanHeaders(IDictionary<string, string> headers)
299298
}
300299
}
301300

302-
private static void ValidateRequest(IRequest request)
301+
internal static void ValidateRequest(IRequest request)
303302
{
304303
Uri url = request.Endpoint;
305304

@@ -630,7 +629,7 @@ public static byte[] ComputeHash(byte[] data)
630629
#endregion
631630

632631
#region Private Signing Helpers
633-
static string SetPayloadSignatureHeader(IRequest request, string payloadHash)
632+
internal static string SetPayloadSignatureHeader(IRequest request, string payloadHash)
634633
{
635634
if (request.Headers.ContainsKey(HeaderKeys.XAmzContentSha256Header))
636635
request.Headers[HeaderKeys.XAmzContentSha256Header] = payloadHash;
@@ -704,7 +703,7 @@ public static string DetermineService(IClientConfig clientConfig, IRequest reque
704703
/// will look for the hash as a header on the request.
705704
/// </param>
706705
/// <returns>Canonicalised request as a string</returns>
707-
protected static string CanonicalizeRequest(Uri endpoint,
706+
protected internal static string CanonicalizeRequest(Uri endpoint,
708707
string resourcePath,
709708
string httpMethod,
710709
IDictionary<string, string> sortedHeaders,
@@ -728,7 +727,7 @@ protected static string CanonicalizeRequest(Uri endpoint,
728727
/// will look for the hash as a header on the request.
729728
/// </param>
730729
/// <returns>Canonicalised request as a string</returns>
731-
protected static string CanonicalizeRequest(Uri endpoint,
730+
protected internal static string CanonicalizeRequest(Uri endpoint,
732731
string resourcePath,
733732
string httpMethod,
734733
IDictionary<string, string> sortedHeaders,
@@ -761,7 +760,7 @@ protected static string CanonicalizeRequest(Uri endpoint,
761760
/// </param>
762761
/// <param name="doubleEncode">Encode "/" when canonicalize resource path</param>
763762
/// <returns>Canonicalised request as a string</returns>
764-
protected static string CanonicalizeRequest(Uri endpoint,
763+
protected internal static string CanonicalizeRequest(Uri endpoint,
765764
string resourcePath,
766765
string httpMethod,
767766
IDictionary<string, string> sortedHeaders,
@@ -866,7 +865,7 @@ protected internal static string CanonicalizeHeaders(IEnumerable<KeyValuePair<st
866865
/// </summary>
867866
/// <param name="sortedHeaders">The headers included in the signature</param>
868867
/// <returns>Formatted string of header names</returns>
869-
protected static string CanonicalizeHeaderNames(IEnumerable<KeyValuePair<string, string>> sortedHeaders)
868+
protected internal static string CanonicalizeHeaderNames(IEnumerable<KeyValuePair<string, string>> sortedHeaders)
870869
{
871870
var builder = new ValueStringBuilder(512);
872871

@@ -886,7 +885,7 @@ protected static string CanonicalizeHeaderNames(IEnumerable<KeyValuePair<string,
886885
/// </summary>
887886
/// <param name="request">The in-flight request being signed</param>
888887
/// <returns>The fused set of parameters</returns>
889-
protected static List<KeyValuePair<string, string>> GetParametersToCanonicalize(IRequest request)
888+
protected internal static List<KeyValuePair<string, string>> GetParametersToCanonicalize(IRequest request)
890889
{
891890
var parametersToCanonicalize = new List<KeyValuePair<string, string>>();
892891

@@ -968,7 +967,7 @@ protected static string CanonicalizeQueryParameters(string queryString, bool uri
968967
return CanonicalizeQueryParameters(queryParams, uriEncodeParameters: uriEncodeParameters);
969968
}
970969

971-
protected static string CanonicalizeQueryParameters(IEnumerable<KeyValuePair<string, string>> parameters)
970+
protected internal static string CanonicalizeQueryParameters(IEnumerable<KeyValuePair<string, string>> parameters)
972971
{
973972
return CanonicalizeQueryParameters(parameters, true);
974973
}

0 commit comments

Comments
 (0)