@@ -493,7 +493,7 @@ private async Task HandleChallengeAsyncInternal(AuthenticationProperties propert
493493 // Push if endpoint is in disco
494494 if ( ! string . IsNullOrEmpty ( parEndpoint ) )
495495 {
496- await PushAuthorizationRequest ( message , properties ) ;
496+ await PushAuthorizationRequest ( message , properties , parEndpoint ) ;
497497 }
498498
499499 break ;
@@ -508,14 +508,13 @@ private async Task HandleChallengeAsyncInternal(AuthenticationProperties propert
508508 break ;
509509 case PushedAuthorizationBehavior . Require :
510510 // Fail if required in options but unavailable in disco
511- var endpointIsConfigured = ! string . IsNullOrEmpty ( parEndpoint ) ;
512- if ( ! endpointIsConfigured )
511+ if ( string . IsNullOrEmpty ( parEndpoint ) )
513512 {
514513 throw new InvalidOperationException ( "Pushed authorization is required by the OpenIdConnectOptions.PushedAuthorizationBehavior, but no pushed authorization endpoint is available." ) ;
515514 }
516515
517516 // Otherwise push
518- await PushAuthorizationRequest ( message , properties ) ;
517+ await PushAuthorizationRequest ( message , properties , parEndpoint ) ;
519518 break ;
520519 }
521520
@@ -550,8 +549,10 @@ private async Task HandleChallengeAsyncInternal(AuthenticationProperties propert
550549 throw new NotImplementedException ( $ "An unsupported authentication method has been configured: { Options . AuthenticationMethod } ") ;
551550 }
552551
553- private async Task PushAuthorizationRequest ( OpenIdConnectMessage authorizeRequest , AuthenticationProperties properties )
552+ private async Task PushAuthorizationRequest ( OpenIdConnectMessage authorizeRequest , AuthenticationProperties properties , string parEndpoint )
554553 {
554+ ArgumentException . ThrowIfNullOrEmpty ( parEndpoint ) ;
555+
555556 // Build context and run event
556557 var parRequest = authorizeRequest . Clone ( ) ;
557558 var context = new PushedAuthorizationContext ( Context , Scheme , Options , parRequest , properties ) ;
@@ -579,20 +580,15 @@ private async Task PushAuthorizationRequest(OpenIdConnectMessage authorizeReques
579580 Logger . PushAuthorizationSkippedPush ( ) ;
580581 return ;
581582 }
583+
582584 // ... or handle pushing to the par endpoint itself, in which case it will supply the request uri
583- else if ( context . HandledPush )
585+ if ( context . HandledPush )
584586 {
585587 Logger . PushAuthorizationHandledPush ( ) ;
586588 requestUri = context . RequestUri ;
587589 }
588590 else
589591 {
590- var parEndpoint = _configuration ? . PushedAuthorizationRequestEndpoint ;
591- if ( string . IsNullOrEmpty ( parEndpoint ) )
592- {
593- new InvalidOperationException ( "Attempt to push authorization with no pushed authorization endpoint configured." ) ;
594- }
595-
596592 var requestMessage = new HttpRequestMessage ( HttpMethod . Post , parEndpoint ) ;
597593 requestMessage . Content = new FormUrlEncodedContent ( parRequest . Parameters ) ;
598594 requestMessage . Version = Backchannel . DefaultRequestVersion ;
0 commit comments