Codebelt.Extensions.AwsSignature4 8.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Codebelt.Extensions.AwsSignature4 --version 8.4.0                
NuGet\Install-Package Codebelt.Extensions.AwsSignature4 -Version 8.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Codebelt.Extensions.AwsSignature4" Version="8.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Codebelt.Extensions.AwsSignature4 --version 8.4.0                
#r "nuget: Codebelt.Extensions.AwsSignature4, 8.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Codebelt.Extensions.AwsSignature4 as a Cake Addin
#addin nuget:?package=Codebelt.Extensions.AwsSignature4&version=8.4.0

// Install Codebelt.Extensions.AwsSignature4 as a Cake Tool
#tool nuget:?package=Codebelt.Extensions.AwsSignature4&version=8.4.0                

About

An open-source project (MIT license) that targets and complements AWS Signature Version 4 for API requests. It aims to provide a good developer experience by making it simple to generate AWS4-HMAC-SHA256 HTTP Authorization header.

It is, by heart, free, flexible and built to extend and boost your agile codebelt.

Codebelt.Extensions.AwsSignature4 for .NET

The Codebelt.Extensions.AwsSignature4 namespace complements the Cuemon.AspNetCore.Authentication namespace while providing a way making and signing HTTP requests in the context of specific AWS services using Signature Version 4.

More documentation available at our documentation site:

CSharp Example

In this example we create an HTTP request with an AWS Signature Version 4 header. The example used here is part of the unit test for Aws4HmacAuthorizationHeaderBuilder. Unit test is based on xUnit API and is written using convenient extensions for xUnit API by Codebelt.

using var host = WebHostTestFactory.Create();
var context = host.ServiceProvider.GetRequiredService<IHttpContextAccessor>().HttpContext;

var timestamp = DateTime.Parse("2022-07-10T12:50:42.2737531Z"); // <-- change this to valid date/time

context.Request.Headers.Add(HttpHeaderNames.Host, "cuemon.s3.amazonaws.com");
context.Request.Headers.Add("x-amz-date", timestamp.ToAwsDateTimeString());
context.Request.Headers.Add("x-amz-content-sha256", UnkeyedHashFactory.CreateCryptoSha256().ComputeHash("").ToHexadecimalString());
context.Request.QueryString = QueryString.Create("list-type", "2");

var headerBuilder = new Aws4HmacAuthorizationHeaderBuilder()
    .AddFromRequest(context.Request)
    .AddClientId("AKIAIOSFODNN7EXAMPLE") // <-- change this to valid access key
    .AddClientSecret("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") // <-- change this to valid secret
    .AddCredentialScope(timestamp);

var header = headerBuilder.Build().ToString(); // <-- AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20220710/eu-west-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=3d2c4a14b38d0283bb697176ade57b2118110de0f00c387d7f0ef58c55a5b91d

Full soucecode: Aws4HmacAuthorizationHeaderBuilderTest

cURL Example

curl --location --request GET 'https://cuemon.s3.amazonaws.com/?list-type=2' --header 'Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20220710/eu-west-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=feeb4c8ba41733fadc73cba6631ddfc9a729f371206bbaa77f216a69dd5299c5' --header 'x-amz-date: 20220710T145042Z' --header 'x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.0.0 70 11/13/2024
9.0.0-rc.1 45 11/12/2024
9.0.0-preview.2 48 10/9/2024
9.0.0-preview.1 47 10/5/2024
8.4.0 95 10/5/2024

Version 8.4.0
Availability: .NET 8 and .NET 6
 
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
 
Version 8.3.2
Availability: .NET 8 and .NET 6
 
# ALM
- REMOVED Support for TFM .NET 7 (STS)
 
Version 8.2.0
Availability: .NET 8, .NET 7 and .NET 6
 
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
 
Version: 8.1.0
Availability: .NET 8, .NET 7 and .NET 6
 
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
 
Version: 8.0.1
Availability: .NET 8, .NET 7 and .NET 6
 
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
 
Version: 8.0.0
Availability: .NET 8, .NET 7 and .NET 6
 
# ALM
- ADDED TFM for net8.0
- REMOVED TFM for netstandard2.0
- CHANGED Dependencies to latest and greatest with respect to TFMs