Issue #6: implement api key hashing and verification #59

Merged
dohertj2 merged 1 commits from agent-2/issue-6-implement-api-key-hashing-and-verification into main 2026-04-26 16:46:07 -04:00
Owner

Implements API key parsing, HMAC-SHA256 hashing with the configured gateway pepper, constant-time hash verification, and identity/scope projection for issue #6.

Covered behavior:

  • parses authorization: Bearer mxgw_<key-id>_<secret>
  • rejects malformed headers before lookup
  • hashes presented secrets with Authentication:PepperSecretName
  • compares hashes using CryptographicOperations.FixedTimeEquals
  • rejects missing, revoked, mismatched, and missing-pepper keys
  • returns key id, prefix, display name, and scopes without raw secrets
  • extends API-key redaction coverage for underscore-containing secrets

Tests run:

  • dotnet format src\MxGateway.sln --verify-no-changes
  • dotnet build src\MxGateway.sln
  • dotnet test src\MxGateway.Tests\MxGateway.Tests.csproj
  • dotnet test src\MxGateway.sln

Closes #6

Implements API key parsing, HMAC-SHA256 hashing with the configured gateway pepper, constant-time hash verification, and identity/scope projection for issue #6. Covered behavior: - parses `authorization: Bearer mxgw_<key-id>_<secret>` - rejects malformed headers before lookup - hashes presented secrets with `Authentication:PepperSecretName` - compares hashes using `CryptographicOperations.FixedTimeEquals` - rejects missing, revoked, mismatched, and missing-pepper keys - returns key id, prefix, display name, and scopes without raw secrets - extends API-key redaction coverage for underscore-containing secrets Tests run: - dotnet format src\MxGateway.sln --verify-no-changes - dotnet build src\MxGateway.sln - dotnet test src\MxGateway.Tests\MxGateway.Tests.csproj - dotnet test src\MxGateway.sln Closes #6
dohertj2 added 1 commit 2026-04-26 16:45:26 -04:00
dohertj2 merged commit 3b3e41acf4 into main 2026-04-26 16:46:07 -04:00
Sign in to join this conversation.