authentication-dotnet-api-key

star 12

Đăng ký Jarvis API Key AddCoreApiKey với IApiKeyProvider tùy chỉnh. Dùng khi client gửi key qua header X-API-KEY hoặc tên tùy config.

hoangnh2412 By hoangnh2412 schedule Updated 5/24/2026

name: authentication-dotnet-api-key description: Đăng ký Jarvis API Key AddCoreApiKey với IApiKeyProvider tùy chỉnh. Dùng khi client gửi key qua header X-API-KEY hoặc tên tùy config. dependencies: - Jarvis.Authentications.ApiKey

API Key

Package

<PackageReference Include="Jarvis.Authentications.ApiKey" Version="1.0.1" />

Program.cs

using Jarvis.Authentication.ApiKey;

builder.Services.AddAuthentication()
    .AddCoreApiKey<MyApiKeyProvider>(builder.Configuration);

builder.Services.AddScoped<MyApiKeyProvider>();

Implement IApiKeyProvider — validate key, map client id.

appsettings.json

{
  "Authentication": {
    "Type": "ApiKey",
    "ApiKey": {
      "Default": {
        "KeyName": "X-API-KEY",
        "Keys": []
      }
    }
  }
}

Keys và secret — chỉ env/secret store, không commit.

Swagger

swashbuckle-dotnet/providers/api-key-security.

Validate

  • Request thiếu/sai header → 401
  • Key hợp lệ → 200 trên endpoint protected
Install via CLI
npx skills add https://github.com/hoangnh2412/jarvis --skill authentication-dotnet-api-key
Repository Details
star Stars 12
call_split Forks 2
navigation Branch main
article Path SKILL.md
More from Creator