HmacFields Class
Definition
- Namespace
- Cuemon.AspNetCore.Authentication.Hmac
- Assemblies
- Cuemon.AspNetCore.Authentication.dll
A collection of constants for HmacAuthorizationHeaderBuilder and related.
public static class HmacFields
- Inheritance
-
HmacFields
Examples
The following example demonstrates how to reference the field constants of HmacFields when building an HMAC authorization header.
using System;
using System.Net.Http;
using Cuemon.AspNetCore.Authentication.Hmac;
namespace MyApp.Examples;
public static class HmacFieldsExample
{
public static void Demonstrate()
{
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.example.com/resource");
request.Headers.Date = DateTimeOffset.UtcNow;
request.Headers.Host = "api.example.com";
var builder = new HmacAuthorizationHeaderBuilder()
.AddFromRequest(request)
.AddClientId("my-client")
.AddClientSecret("my-secret")
.AddCredentialScope("20250101/us-east-1/service/aws4_request");
var header = builder.Build();
Console.WriteLine(HmacFields.Scheme);
Console.WriteLine(HmacFields.SignedHeaders);
Console.WriteLine(HmacFields.CanonicalRequest);
}
}
Fields
| Name | Description |
|---|---|
| CanonicalRequest | The parts of the canonical request. |
| ClientId | The public key of the signing process. |
| ClientSecret | The private key of the signing process. |
| CredentialScope | The credential scope that defines the remote resource. |
| HttpHeaders | The canonical headers. |
| HttpHeadersDelimiter | The delimiter used to separate the key-value pairs of HttpHeaders. |
| HttpMethod | The HTTP request method. |
| Payload | The request payload. |
| Scheme | The default authentication scheme of the HmacAuthorizationHeader. |
| ServerDateTime | The server date time expressed in ISO 8601 format. |
| SignedHeaders | The headers that must be part of the signing process. |
| SignedHeadersDelimiter | The delimiter used to separate the SignedHeaders. |
| StringToSign | The parts of the string to sign. |
| UriPath | The canonical URI that is the URI-encoded version of the absolute path component of an URI. |
| UriQuery | The canonical query string. |