Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 1887bfa

Browse files
committed
Enable PAR by default when it is supported by the provider
1 parent c99f19b commit 1887bfa

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

clients/ConsoleClientWithBrowser/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ private static async Task SignIn()
4747
Browser = browser,
4848
IdentityTokenValidator = new JwtHandlerIdentityTokenValidator(),
4949
RefreshTokenInnerHttpHandler = new SocketsHttpHandler(),
50-
51-
UsePushedAuthorization = true
5250
};
5351

5452
var serilog = new LoggerConfiguration()

clients/ConsoleClientWithBrowserAndDPoP/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ private static async Task SignIn()
4747
RedirectUri = redirectUri,
4848
Scope = "openid profile api offline_access",
4949
FilterClaims = false,
50-
Browser = browser,
51-
UsePushedAuthorization = true
50+
Browser = browser
5251
};
5352

5453
options.ConfigureDPoP(proofKey);

src/OidcClient/AuthorizeClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ public async Task<AuthorizeState> CreateAuthorizeStateAsync(Parameters frontChan
105105
CodeVerifier = pkce.CodeVerifier,
106106
};
107107

108-
if(_options.UsePushedAuthorization)
108+
if(_options.ProviderInformation.PushedAuthorizationRequestEndpoint.IsPresent() &&
109+
!_options.DisablePushedAuthorization)
109110
{
111+
_logger.LogDebug("The IdentityProvider contains a pushed authorization request endpoint. Automatically pushing authorization parameters. Use DisablePushedAuthorization to opt out.");
110112
var parResponse = await PushAuthorizationRequestAsync(state.State, pkce.CodeChallenge, frontChannelParameters);
111113
if(parResponse.IsError)
112114
{

src/OidcClient/OidcClientOptions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,10 @@ public class OidcClientOptions
245245
};
246246

247247
/// <summary>
248-
/// Gets or sets a flag to enable Pushed Authorization Requests (PAR).
248+
/// Gets or sets a flag to disable Pushed Authorization Requests (PAR).
249+
/// By default, we use PAR when there is a configured PAR endpoint or
250+
/// when the discovery endpoint indicates that it supports PAR.
249251
/// </summary>
250-
public bool UsePushedAuthorization { get; set; }
252+
public bool DisablePushedAuthorization { get; set; } = false;
251253
}
252254
}

0 commit comments

Comments
 (0)