Cloud.Net.Sdk.Hmac 5.0.1

dotnet add package Cloud.Net.Sdk.Hmac --version 5.0.1                
NuGet\Install-Package Cloud.Net.Sdk.Hmac -Version 5.0.1                
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="Cloud.Net.Sdk.Hmac" Version="5.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cloud.Net.Sdk.Hmac --version 5.0.1                
#r "nuget: Cloud.Net.Sdk.Hmac, 5.0.1"                
#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 Cloud.Net.Sdk.Hmac as a Cake Addin
#addin nuget:?package=Cloud.Net.Sdk.Hmac&version=5.0.1

// Install Cloud.Net.Sdk.Hmac as a Cake Tool
#tool nuget:?package=Cloud.Net.Sdk.Hmac&version=5.0.1                

Source: https://github.com/khanhhc2021/hmac

DotNet HMAC Authentication

DotNet HMAC Authentication is a library using for server Authentication HTTP Header and client signing header request. This algorithm base on AWS4 HMAC Authentication.

Installation

Support for dot net core only, version >= 2.2

Install-Package Cloud.Net.Sdk.Hmac
OR
dotnet add package Cloud.Net.Sdk.Hmac

Usage

Authentication

Startup.cs
public void ConfigureServices(IServiceCollection services)
{
 //..           
 services.AddAuthentication(HMACAuthOptions.Scheme).AddScheme<HMACAuthOptions, CustomAuthHandler>(HMACAuthOptions.Scheme, null);
 //..          
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
  //..
  app.UseAuthentication(); 
  app.Use(next => context => { context.Request.EnableRewind(); return next(context); });
  //..
}

ApiController.cs
[Authorize(AuthenticationSchemes = HMACAuthOptions.Scheme)]
[HttpGet]  
public ActionResult<IEnumerable<string>> Get()
{
   //..
}

appsettings.json add this config
"HMAC_KEY_CONFIG": {
        "ClientId": "8bf49c695244120399b2c5a00cdbdb9b",
        "SecretKey": "1f48072533be925008777c618c71d492de0294f8"
    }

Signer

   var endpointUri = "https://domaintest.vn/authz/v1/oauth/verifytoken/1";
   var restApi = new RestApiHmac<object>();
   var result = restApi.DoRequestV2(HttpMethod.GET, endpointUri, _cLientId, _clientSecret, null);

Use Mothod DoRequestV1 if you want response format:

   public class ApiJsonResultData<T>
    {
        public bool Success { get; set; }
        public T Data { get; set; }
        public string ErrorMessage { get; set; }
    }

Use Mothod DoRequestV2 if you want response format:

    public class ApiResponse<T>
    {
        public string Code { get; set; }
        public string Message { get; set; }
        public T Data { get; set; }
        public TokenMetaDataVerifyResponse Metadata { get; set; }
    }
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Cloud.Net.Sdk.Hmac:

Package Downloads
CoreEngine

Package for common blocks when build web service application.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.0.1 1,555 5/27/2022
5.0.0 2,204 3/9/2021
3.1.2 1,277 12/10/2020
3.1.1 483 12/8/2020
1.0.9 577 6/24/2022
1.0.8 481 6/21/2022
1.0.6 2,446 7/22/2020
1.0.5 1,931 11/25/2019
1.0.4 1,929 9/16/2019
1.0.3 1,802 8/28/2019
1.0.2 649 8/15/2019
1.0.1 561 8/14/2019