Combination of AccessTokenManagement and custom Pushed Authorization Request #625
Unanswered
iseneirik
asked this question in
Open Source
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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
Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandleronly handles a single resource.To do this, we register our own handler on
Events.OnPushAuthorizationthat wraps the inner handler and does our custom PAR-flow:At the same time, we also use
.AddOpenIdConnectAccessTokenManagement(...)fromDuende.AccessTokenManagement.OpenIdConnect, which wires up its own handler for the PAR-flow, which in turn becomes theinnerHandlerof the above code.The new version (4.2) of
Duende.AccessTokenManagement.OpenIdConnectintroduces a breaking change for us, more precisely the change found on lines 158-174 of access-token-management/src/AccessTokenManagement.OpenIdConnect/Internal/ConfigureOpenIdConnectOptions.cs.What happens is this (with reference to the above snippet):
Duende.AccessTokenManagement.OpenIdConnect, this setsClientAssertionTypeandClientAssertionand callscontext.HandleClientAuthentication()PushedAuthorizationRequestand callPushAuthorizationAsync(...)(fromDuende.IdentityModel)ProtocolRequest.Prepare()is called, which attempts to writeClientAssertionTypeandClientAssertionfrom ourPushedAuthorizationRequest. This was already done in step 1, so it ends up with a "Duplicate parameter..." error (line 212 ofProtocolRequest)ClientAssertionin ourPushedAuthorizationRequest, letting the inner handler do its job, which seems fine.PushAuthorizationAsync(...)we continue by callingpushedAuthorizationContext.HandlePush(...)so thatOpenIdConnectHandlerdoesn't do the PAR for us. This results in:"Only one of HandlePush, SkipPush, and HandledClientAuthentication may be called in the OnPushAuthorization event."because ofcontext.HandleClientAuthentication()being called in step 1.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?
All reactions