Skip to content

Commit 84d8606

Browse files
committed
Fix for pre-populated Events in .NET 10
1 parent 0f8d690 commit 84d8606

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

BFF/v4/DPoP/DPoP.Api/DPoP/ConfigureJwtBearerOptions.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,23 @@ public void PostConfigure(string name, JwtBearerOptions options)
1919
{
2020
if (_configScheme == name)
2121
{
22-
if (options.EventsType != null && !typeof(DPoPJwtBearerEvents).IsAssignableFrom(options.EventsType))
22+
var dpopEventsType = typeof(DPoPJwtBearerEvents);
23+
if (options.EventsType != null && !dpopEventsType.IsAssignableFrom(options.EventsType))
2324
{
2425
throw new Exception("EventsType on JwtBearerOptions must derive from DPoPJwtBearerEvents to work with the DPoP support.");
2526
}
26-
if (options.Events != null && !typeof(DPoPJwtBearerEvents).IsAssignableFrom(options.Events.GetType()))
27-
{
28-
throw new Exception("Events on JwtBearerOptions must derive from DPoPJwtBearerEvents to work with the DPoP support.");
29-
}
3027

31-
if (options.Events == null && options.EventsType == null)
28+
if (!dpopEventsType.IsInstanceOfType(options.Events))
3229
{
33-
options.EventsType = typeof(DPoPJwtBearerEvents);
30+
if (typeof(JwtBearerEvents) == options.Events.GetType())
31+
{
32+
// Default scenario where the events type wasn't overridden?
33+
options.EventsType = dpopEventsType;
34+
}
35+
else
36+
{
37+
throw new Exception("Events on JwtBearerOptions must derive from DPoPJwtBearerEvents to work with the DPoP support.");
38+
}
3439
}
3540
}
3641
}

0 commit comments

Comments
 (0)