Table of Contents

Class HmacFields

Namespace
Cuemon.AspNetCore.Authentication.Hmac
Assembly
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

CanonicalRequest

The parts of the canonical request.

public const string CanonicalRequest = "canonicalRequest"

Field Value

string

ClientId

The public key of the signing process.

public const string ClientId = "clientId"

Field Value

string

ClientSecret

The private key of the signing process.

public const string ClientSecret = "clientSecret"

Field Value

string

CredentialScope

The credential scope that defines the remote resource.

public const string CredentialScope = "credentialScope"

Field Value

string

HttpHeaders

The canonical headers.

public const string HttpHeaders = "canonicalHeaders"

Field Value

string

HttpHeadersDelimiter

The delimiter used to separate the key-value pairs of HttpHeaders.

public const char HttpHeadersDelimiter = ':'

Field Value

char

HttpMethod

The HTTP request method.

public const string HttpMethod = "httpRequestMethod"

Field Value

string

Payload

The request payload.

public const string Payload = "requestPayload"

Field Value

string

Scheme

The default authentication scheme of the HmacAuthorizationHeader.

public const string Scheme = "HMAC"

Field Value

string

Remarks

ServerDateTime

The server date time expressed in ISO 8601 format.

public const string ServerDateTime = "serverDateTime"

Field Value

string

SignedHeaders

The headers that must be part of the signing process.

public const string SignedHeaders = "signedHeaders"

Field Value

string

SignedHeadersDelimiter

The delimiter used to separate the SignedHeaders.

public const char SignedHeadersDelimiter = ';'

Field Value

char

StringToSign

The parts of the string to sign.

public const string StringToSign = "stringToSign"

Field Value

string

UriPath

The canonical URI that is the URI-encoded version of the absolute path component of an URI.

public const string UriPath = "canonicalUri"

Field Value

string

UriQuery

The canonical query string.

public const string UriQuery = "canonicalQueryString"

Field Value

string