Is it possible to make "AddBff" indifferent to order? #347
-
Before summer we added DPoP to our auth-flow, and spent some time debugging when things didn't go as expected. What we found out is that our call to public void Configure(string? name, OpenIdConnectOptions options)
{
if (_configScheme == name)
{
// add the event handling to enable DPoP for this OIDC client
options.Events.OnRedirectToIdentityProvider = CreateCallback(options.Events.OnRedirectToIdentityProvider);
options.Events.OnAuthorizationCodeReceived = CreateCallback(options.Events.OnAuthorizationCodeReceived);
options.Events.OnTokenValidated = CreateCallback(options.Events.OnTokenValidated);
options.BackchannelHttpHandler = new AuthorizationServerDPoPHandler(_dPoPProofService, _dPoPNonceStore, _httpContextAccessor, _loggerFactory)
{
InnerHandler = options.BackchannelHttpHandler ?? new HttpClientHandler()
};
}
} Our solution to this was to change the order of where we add our My question is the following: are there more considerations to be made, or can the following change be made to public static IServiceCollection AddOpenIdConnectAccessTokenManagement(this IServiceCollection services)
{
// ...
- services.ConfigureOptions<ConfigureOpenIdConnectOptions>();
+ services.AddSingleton<IPostConfigureOptions<OpenIdConnectOptions>, ConfigureOpenIdConnectOptions>();
// ...
return services;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @iseneirik, Thank you for your question and sorry to hear you had issues applying DPOP to your flow. We're investigating what the possibilities are here and will report back as soon as possible. |
Beta Was this translation helpful? Give feedback.
-
Hey @iseneirik, we've had a look at this and unfortunately we don't believe there is much we can do. You're correct that there is an ordering issue. However, moving to The underlying issue is that the So, this is an ordering problem which we don't believe we can elegantly resolve. We should be clearer in the documentation. We will also look if it's possible to raise a warning from the system if this is configured incorrectly. |
Beta Was this translation helpful? Give feedback.
Hey @iseneirik, we've had a look at this and unfortunately we don't believe there is much we can do. You're correct that there is an ordering issue. However, moving to
PostConfigureOptions
also creates an ordering issue.The underlying issue is that the
AddOpenIdConnect
call from Microsoft constructs an HTTP Client from theBackChannelHttpHandler
. If we change ourConfigureOpenIdConnectOptions
to also be post configure, the MicrosoftAddOpenIdConnect
invocation might construct theHttpClient
using theBackChannelHttpHandler
before we are able to set it.So, this is an ordering problem which we don't believe we can elegantly resolve. We should be clearer in the documentation. We will also …