@@ -493,7 +493,7 @@ private async Task HandleChallengeAsyncInternal(AuthenticationProperties propert
493
493
// Push if endpoint is in disco
494
494
if ( ! string . IsNullOrEmpty ( parEndpoint ) )
495
495
{
496
- await PushAuthorizationRequest ( message , properties ) ;
496
+ await PushAuthorizationRequest ( message , properties , parEndpoint ) ;
497
497
}
498
498
499
499
break ;
@@ -508,14 +508,13 @@ private async Task HandleChallengeAsyncInternal(AuthenticationProperties propert
508
508
break ;
509
509
case PushedAuthorizationBehavior . Require :
510
510
// Fail if required in options but unavailable in disco
511
- var endpointIsConfigured = ! string . IsNullOrEmpty ( parEndpoint ) ;
512
- if ( ! endpointIsConfigured )
511
+ if ( string . IsNullOrEmpty ( parEndpoint ) )
513
512
{
514
513
throw new InvalidOperationException ( "Pushed authorization is required by the OpenIdConnectOptions.PushedAuthorizationBehavior, but no pushed authorization endpoint is available." ) ;
515
514
}
516
515
517
516
// Otherwise push
518
- await PushAuthorizationRequest ( message , properties ) ;
517
+ await PushAuthorizationRequest ( message , properties , parEndpoint ) ;
519
518
break ;
520
519
}
521
520
@@ -550,8 +549,10 @@ private async Task HandleChallengeAsyncInternal(AuthenticationProperties propert
550
549
throw new NotImplementedException ( $ "An unsupported authentication method has been configured: { Options . AuthenticationMethod } ") ;
551
550
}
552
551
553
- private async Task PushAuthorizationRequest ( OpenIdConnectMessage authorizeRequest , AuthenticationProperties properties )
552
+ private async Task PushAuthorizationRequest ( OpenIdConnectMessage authorizeRequest , AuthenticationProperties properties , string parEndpoint )
554
553
{
554
+ ArgumentException . ThrowIfNullOrEmpty ( parEndpoint ) ;
555
+
555
556
// Build context and run event
556
557
var parRequest = authorizeRequest . Clone ( ) ;
557
558
var context = new PushedAuthorizationContext ( Context , Scheme , Options , parRequest , properties ) ;
@@ -579,20 +580,15 @@ private async Task PushAuthorizationRequest(OpenIdConnectMessage authorizeReques
579
580
Logger . PushAuthorizationSkippedPush ( ) ;
580
581
return ;
581
582
}
583
+
582
584
// ... 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 )
584
586
{
585
587
Logger . PushAuthorizationHandledPush ( ) ;
586
588
requestUri = context . RequestUri ;
587
589
}
588
590
else
589
591
{
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
-
596
592
var requestMessage = new HttpRequestMessage ( HttpMethod . Post , parEndpoint ) ;
597
593
requestMessage . Content = new FormUrlEncodedContent ( parRequest . Parameters ) ;
598
594
requestMessage . Version = Backchannel . DefaultRequestVersion ;
0 commit comments