Skip to content

HMAC - Key rotation#32

Merged
doerrD merged 13 commits intomasterfrom
features/key-rotation
Mar 4, 2026
Merged

HMAC - Key rotation#32
doerrD merged 13 commits intomasterfrom
features/key-rotation

Conversation

@doerrD
Copy link
Copy Markdown
Member

@doerrD doerrD commented Mar 2, 2026

No description provided.

@doerrD doerrD changed the title Features/key rotation HMAC - Key rotation Mar 2, 2026
@doerrD doerrD requested a review from Copilot March 2, 2026 10:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds key rotation support to the HMAC authentication flow by allowing multiple API keys per AppId, updating the authorization provider result shape, and extending the ASP.NET Core handler and tests accordingly.

Changes:

  • Extend AuthorizationProviderResult to expose ApiKeys (multi-key) while keeping ApiKey as the primary/first key.
  • Update MemoryHmacAuthenticationProvider and HmacAuthenticationHandler to validate incoming signatures against multiple keys.
  • Bump package versions / release notes and add tests for multi-key authorization behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
softaware.Authentication.Hmac/softaware.Authentication.Hmac.csproj Bumps core package version to reflect new functionality.
softaware.Authentication.Hmac/AuthorizationProvider/MemoryHmacAuthenticationProvider.cs Adds multi-key constructor and returns multi-key results.
softaware.Authentication.Hmac/AuthorizationProvider/AuthorizationProviderResult.cs Adds ApiKeys and a multi-key constructor for key rotation support.
softaware.Authentication.Hmac.AspNetCore/softaware.Authentication.Hmac.AspNetCore.csproj Bumps ASP.NET Core package version and updates release notes for key rotation.
softaware.Authentication.Hmac.AspNetCore/HmacAuthenticationHandler.cs Tries signature validation against multiple keys; modifies replay detection logic.
softaware.Authentication.Hmac.AspNetCore.Test/MiddlewareTest.cs Adds new tests validating authorization with primary/secondary keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +22
this.hmacAuthenticatedApps = hmacAuthenticatedApps.ToDictionary(
kvp => kvp.Key,
kvp => new[] { kvp.Value });
}
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MemoryHmacAuthenticationProvider used to keep a reference to the provided IDictionary, preserving custom key comparers (e.g., case-insensitive) and reflecting any updates made after construction. The new ToDictionary copy uses the default comparer and is a snapshot, which can be a breaking behavior change. Consider preserving the source comparer when possible and/or documenting the snapshot semantics explicitly.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be much of an issue I'd say

Copy link
Copy Markdown
Member

@meinsiedler meinsiedler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extend the README.md to describe the key rotation for HMAC

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 2, 2026

@doerrD I've opened a new pull request, #34, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits March 2, 2026 12:31
Co-authored-by: doerrD <5888867+doerrD@users.noreply.github.com>
Fix nonce replay protection (per-request MemoryCache) and add regression test
@doerrD doerrD requested a review from meinsiedler March 4, 2026 14:00
@doerrD doerrD merged commit 4db9175 into master Mar 4, 2026
1 check passed
@meinsiedler meinsiedler deleted the features/key-rotation branch March 5, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants