Class Aws4HmacAuthorizationHeaderBuilder
- Namespace
- Codebelt.Extensions.AwsSignature4
- Assembly
- Codebelt.Extensions.AwsSignature4.dll
Provides a way to fluently represent a HTTP AWS4-HMAC-SHA256 Authentication header.
public class Aws4HmacAuthorizationHeaderBuilder : HmacAuthorizationHeaderBuilder<Aws4HmacAuthorizationHeaderBuilder>
- Inheritance
-
Aws4HmacAuthorizationHeaderBuilder
- Inherited Members
Remarks
Constructors
Aws4HmacAuthorizationHeaderBuilder()
Initializes a new instance of the Aws4HmacAuthorizationHeaderBuilder class.
public Aws4HmacAuthorizationHeaderBuilder()
Methods
AddCredentialScope(DateTime, String, String, String)
Adds the credential scope that defines the remote resource.
public Aws4HmacAuthorizationHeaderBuilder AddCredentialScope(DateTime timestamp, string region = "eu-west-1", string service = "s3", string termination = "aws4_request")
Parameters
timestamp
DateTimeThe DateTime value part of the credential scope.
region
StringThe AWS region part of the credential scope. Default is
eu-west-1
.service
StringThe service name part of the credential scope. Default is
s3
(Simple Storage Service).termination
StringThe termination string part of the credential scope. Default is
aws4_request
.
Returns
- Aws4HmacAuthorizationHeaderBuilder
A reference to this instance so that additional calls can be chained.
Remarks
The following string represents the scope part of the Credential parameter for a S3 request in the eu-west-1 Region: 20220710/eu-west-1/s3/aws4_request
AddFromRequest(HttpRequest)
Adds the necessary fields that is part of an HTTP request.
public override Aws4HmacAuthorizationHeaderBuilder AddFromRequest(HttpRequest request)
Parameters
request
HttpRequestAn instance of the Microsoft.AspNetCore.Http.HttpRequest object.
Returns
- Aws4HmacAuthorizationHeaderBuilder
A reference to this instance so that additional calls can be chained.
Build()
Builds an instance of HmacAuthorizationHeader that implements AuthorizationHeader.
public override HmacAuthorizationHeader Build()
Returns
- HmacAuthorizationHeader
An instance of HmacAuthorizationHeader.
Remarks
ComputeCanonicalRequest()
Converts the request to a standardized (canonical) format and computes a message digest.
public override string ComputeCanonicalRequest()
Returns
Remarks
ComputeSignature()
Computes the signature of this instance using a series of hash-based message authentication codes (HMACs).
public override string ComputeSignature()
Returns
Remarks
https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html, https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html