Entra.EventHandlers 1.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Entra.EventHandlers --version 1.5.0
                    
NuGet\Install-Package Entra.EventHandlers -Version 1.5.0
                    
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="Entra.EventHandlers" Version="1.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Entra.EventHandlers" Version="1.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Entra.EventHandlers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Entra.EventHandlers --version 1.5.0
                    
#r "nuget: Entra.EventHandlers, 1.5.0"
                    
#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.
#:package Entra.EventHandlers@1.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Entra.EventHandlers&version=1.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Entra.EventHandlers&version=1.5.0
                    
Install as a Cake Tool

Entra.EventHandlers

Production-ready implementation layer for Microsoft Entra External ID authentication event handlers.

This package builds on top of the MIT-licensed Entra.EventHandlers.Abstractions package and provides fluent response builders, handler base classes, validation, logging, and other developer-focused capabilities for building Microsoft Entra External ID custom authentication extensions.

This package focuses exclusively on External ID events.

Microsoft Entra Workforce events are provided separately by Entra.EventHandlers.Workforce.

Installation

dotnet add package Entra.EventHandlers

Features

  • Fluent response builders
  • Strongly typed event models
  • Strongly typed response models
  • Event handler base classes
  • Structured logging
  • Correlation ID logging
  • Protocol validation
  • Exception handling
  • Execution timing
  • Dependency injection integration
  • Fully testable architecture

Supported External ID Events

  • AttributeCollectionStart
  • AttributeCollectionSubmit
  • EmailOtpSend
  • PasswordSubmit
  • TokenIssuanceStart

Each event includes:

  • Event models
  • Response models
  • Handler base classes
  • Fluent response builders
  • Validation support

Unified Response Builder API

All External ID response builders are available through a single entry point:

EntraEventResponses.AttributeCollectionStart();

EntraEventResponses.AttributeCollectionSubmit();

EntraEventResponses.EmailOtpSend();

EntraEventResponses.PasswordSubmit();

EntraEventResponses.TokenIssuanceStart();

This provides a consistent and discoverable experience across all supported events.


Building Responses

Example:

return EntraEventResponses
    .AttributeCollectionStart()
    .SetPrefillValues()
        .Add("email", "user@example.com")
        .Add("country", "PL")
    .Done()
    .Build();

The fluent builders ensure protocol-correct responses without requiring manual JSON construction.


Implementing a Handler

Create a handler by inheriting from the appropriate event-specific base class.

Example:

public class TokenIssuanceStartHandler(
    ILogger<TokenIssuanceStartHandler> logger)
    : TokenIssuanceStartHandlerBase(logger)
{
    protected override Task<TokenIssuanceStartResponse> HandleCoreAsync(
        TokenIssuanceStartEvent request,
        CancellationToken cancellationToken = default)
    {
        var userId =
            request.Data.AuthenticationContext?.User?.Id;

        var roles = userId switch
        {
            var id when id ==
                Guid.Parse("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
                    => ["Admin", "PowerUser"],

            _ => ["User"]
        };

        var customClaims = new Dictionary<string, object>
        {
            ["tenantId"] = "contoso-eu",
            ["department"] = "Engineering",
            ["roles"] = roles
        };

        return Task.FromResult(
            EntraEventResponses
                .TokenIssuanceStart()
                .ProvideClaimsForToken(customClaims)
                .Build());
    }
}

The base class automatically provides:

  • Request validation
  • Structured logging
  • Correlation ID logging
  • Event type logging
  • Execution timing
  • Exception handling

This allows handlers to focus entirely on business logic.


PasswordSubmit Support

The package includes the PasswordSubmit handler infrastructure.

Example:

public class PasswordSubmitHandler(
    ILogger<PasswordSubmitHandler> logger,
    IPasswordContextDecryptor decryptor)
    : PasswordSubmitHandlerBase(logger, decryptor)
{
    protected override Task<PasswordSubmitResponse> HandleCoreAsync(
        PasswordSubmitEvent request,
        DecryptedPasswordContext decrypted,
        CancellationToken cancellationToken = default)
    {
        return Task.FromResult(
            EntraEventResponses
                .PasswordSubmit()
                .WithNonce(decrypted.Nonce)
                .MigratePassword()
                .Build());
    }
}

For Azure Key Vault-based password decryption support, see:

  • Entra.EventHandlers.Security

Testing

Handlers are designed to be tested directly without ASP.NET Core or Azure Functions hosting infrastructure.

Example:

var result = await handler.HandleAsync(request);

Benefits include:

  • Fast unit tests
  • Easier mocking
  • Better separation of concerns
  • Higher test coverage

Business logic should live inside handlers while hosting adapters remain thin transport layers.


Samples

Shared handler implementations are available in:

https://github.com/szubajak/entra-event-handlers/tree/main/samples/Sample.Common

The sample demonstrates:

  • Handler base classes
  • Fluent response builders
  • Custom claims
  • Prefill values
  • Validation responses
  • Block pages
  • Production-ready handler patterns

These handlers are reused by both the ASP.NET Core and Azure Functions sample applications.


Documentation

Full documentation, event guides, hosting guides, testing guidance, security guidance, and samples:

https://github.com/szubajak/entra-event-handlers/tree/main/docs

Microsoft Entra External ID authentication event handlers documentation:

https://github.com/szubajak/entra-event-handlers/tree/main/docs/events

AI-friendly repository metadata:

https://github.com/szubajak/entra-event-handlers/blob/main/llms.txt


Package Purpose
Entra.EventHandlers.Abstractions Public contracts and protocol models
Entra.EventHandlers.Workforce Workforce implementation layer
Entra.EventHandlers.AspNetCore ASP.NET Core hosting
Entra.EventHandlers.AzureFunctions Azure Functions hosting
Entra.EventHandlers.Security PasswordSubmit decryption and Azure Key Vault integration

License

This package is licensed under the Business Source License (BSL).

The Entra.EventHandlers.Abstractions package is licensed under MIT and may be used freely.

See the repository for licensing details and commercial licensing information.


Further Reading

Entra External ID .NET Handlers Deep Dive

https://medium.com/@jakub.szubarga/entra-external-id-dotnet-handlers-a7447dc1e437

Building CIAM-Ready Azure Functions with Entra.EventHandlers

https://medium.com/@jakub.szubarga/entra-eventhandlers-ciam-azure-functions-97c5e1940272

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.0 131 11/16/2026
1.5.3 160 10/27/2026
1.5.2 110 10/26/2026
1.5.1 129 10/14/2026
1.5.0 131 10/9/2026
1.4.1 137 9/23/2026
1.4.0 125 9/14/2026
1.3.6 152 9/10/2026
1.3.5 192 7/16/2026
1.3.4 216 6/26/2026
1.3.3 196 6/25/2026
1.3.2 198 6/18/2026
1.3.1 196 6/11/2026
1.3.0 146 6/10/2026
1.2.10 169 6/8/2026
1.2.9 175 6/8/2026
1.2.8 155 6/8/2026
1.2.7 405 6/7/2026
1.2.6 171 6/6/2026
1.2.5 179 6/6/2026
Loading failed

Includes fluent response builders, production-ready handler base classes, protocol validation,
structured logging, correlation scopes, and the unified execution pipeline for Microsoft Entra
External ID Authentication Event Handlers. Designed for use with the ASP.NET Core and Azure
Functions hosting adapters.