Combination of AccessTokenManagement and custom Pushed Authorization Request #625
|
Hi, We are integrating with an OIDC-provider (HelseId) where we need to write custom logic for PAR, as we need to send multiple resources in the request, whereas the standard PAR-handling in To do this, we register our own handler on private static Func<PushedAuthorizationContext, Task> HandlePushAuthorization(Func<PushedAuthorizationContext, Task> innerHandler) =>
async pushedAuthorizationContext =>
{
await innerHandler.Invoke(pushedAuthorizationContext);
// ... Omitted for brevity
var clientAssertion = await assertionService.GetClientAssertionAsync();
var parRequest = new PushedAuthorizationRequest
{
Parameters = new Parameters(pushedAuthorizationContext.ProtocolMessage.Parameters),
Address = $"{config.HelseId.Authority}/connect/par",
ClientCredentialStyle = ClientCredentialStyle.PostBody,
ClientAssertion = clientAssertion!,
AcrValues = config.HelseId.GetAcrValues(amr),
Resource = resource as ICollection<string> ?? [],
};
var response = await pushedAuthorizationContext.Options.Backchannel.PushAuthorizationAsync(parRequest);
// ... Omitted for brevity
pushedAuthorizationContext.HandlePush(response.RequestUri!);
};At the same time, we also use The new version (4.2) of What happens is this (with reference to the above snippet):
The solution for us is to just omit calling the inner handler entirely, which seems to work fine. The reason I'm posting this is because we get a sense that we are doing something wrong since the libraries you provide don't play well together for this scenario. Are we correct in handling it this way? Or is there a better way for handling PAR with multiple resources? |
Replies: 1 comment 1 reply
|
PR 345 introduced regenerating client assertions to enable retrying DPoP nonce requests. In your use case, you need to take ownership of generating the PAR request yourself because of the requirement of sending multiple resource URIs. So I don't think you're doing anything wrong here. I would agree that the best approach is to not call the inner handler from |
PR 345 introduced regenerating client assertions to enable retrying DPoP nonce requests. In your use case, you need to take ownership of generating the PAR request yourself because of the requirement of sending multiple resource URIs. So I don't think you're doing anything wrong here.
I would agree that the best approach is to not call the inner handler from
Duende.AccessTokenManagement.OpenIdConnect. Since you're also setting the client assertion retrieved from theIClientAssertionService, you're basically doing the same thing as the inner handler (and more).