From ac4df6f74d800a9434af0c2287c5fa8b28ba9161 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Mon, 7 Jul 2025 18:40:29 -0700 Subject: [PATCH] Update all built-in AuthenticationSchemeOptions to initialize Events --- .../Certificate/src/CertificateAuthenticationOptions.cs | 8 ++++++++ .../Authentication/JwtBearer/src/JwtBearerOptions.cs | 1 + .../Authentication/Negotiate/src/NegotiateOptions.cs | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/src/Security/Authentication/Certificate/src/CertificateAuthenticationOptions.cs b/src/Security/Authentication/Certificate/src/CertificateAuthenticationOptions.cs index 693dd5da942a..cdb6598cf62a 100644 --- a/src/Security/Authentication/Certificate/src/CertificateAuthenticationOptions.cs +++ b/src/Security/Authentication/Certificate/src/CertificateAuthenticationOptions.cs @@ -10,6 +10,14 @@ namespace Microsoft.AspNetCore.Authentication.Certificate; /// public class CertificateAuthenticationOptions : AuthenticationSchemeOptions { + /// + /// Initializes a new instance of . + /// + public CertificateAuthenticationOptions() + { + Events = new CertificateAuthenticationEvents(); + } + /// /// Value indicating the types of certificates accepted by the authentication middleware. /// diff --git a/src/Security/Authentication/JwtBearer/src/JwtBearerOptions.cs b/src/Security/Authentication/JwtBearer/src/JwtBearerOptions.cs index f5b56ed32531..c4142a40da73 100644 --- a/src/Security/Authentication/JwtBearer/src/JwtBearerOptions.cs +++ b/src/Security/Authentication/JwtBearer/src/JwtBearerOptions.cs @@ -32,6 +32,7 @@ public JwtBearerOptions() SecurityTokenValidators = new List { _defaultHandler }; #pragma warning restore CS0618 // Type or member is obsolete TokenHandlers = new List { _defaultTokenHandler }; + Events = new JwtBearerEvents(); } /// diff --git a/src/Security/Authentication/Negotiate/src/NegotiateOptions.cs b/src/Security/Authentication/Negotiate/src/NegotiateOptions.cs index b170eeb6b7e4..b4fe727ad813 100644 --- a/src/Security/Authentication/Negotiate/src/NegotiateOptions.cs +++ b/src/Security/Authentication/Negotiate/src/NegotiateOptions.cs @@ -8,6 +8,14 @@ namespace Microsoft.AspNetCore.Authentication.Negotiate; /// public class NegotiateOptions : AuthenticationSchemeOptions { + /// + /// Initializes a new instance of . + /// + public NegotiateOptions() + { + Events = new NegotiateEvents(); + } + /// /// The object provided by the application to process events raised by the negotiate authentication handler. /// The application may use the existing NegotiateEvents instance and assign delegates only to the events it