@@ -183,10 +183,11 @@ public function login(int $providerId, ?string $redirectUrl = null) {
183183 $ this ->session ->set (self ::NONCE , $ nonce );
184184
185185 $ oidcSystemConfig = $ this ->config ->getSystemValue ('user_oidc ' , []);
186- // TODO add config param to force PKCE even if not supported in discovery
187186 // condition becomes: ($isPkceSupported || $force) && ($oidcSystemConfig['use_pkce'] ?? true)
188187 $ isPkceSupported = in_array ('S256 ' , $ discovery ['code_challenge_methods_supported ' ] ?? [], true );
189- $ isPkceEnabled = $ isPkceSupported && ($ oidcSystemConfig ['use_pkce ' ] ?? true );
188+ $ usePkce = $ oidcSystemConfig ['use_pkce ' ] ?? true ;
189+ $ forcePkce = $ usePkce === 'force ' ;
190+ $ isPkceEnabled = $ forcePkce || ($ isPkceSupported && $ usePkce );
190191
191192 if ($ isPkceEnabled ) {
192193 // PKCE code_challenge see https://datatracker.ietf.org/doc/html/rfc7636
@@ -378,7 +379,9 @@ public function code(string $state = '', string $code = '', string $scope = '',
378379
379380 $ oidcSystemConfig = $ this ->config ->getSystemValue ('user_oidc ' , []);
380381 $ isPkceSupported = in_array ('S256 ' , $ discovery ['code_challenge_methods_supported ' ] ?? [], true );
381- $ isPkceEnabled = $ isPkceSupported && ($ oidcSystemConfig ['use_pkce ' ] ?? true );
382+ $ usePkce = $ oidcSystemConfig ['use_pkce ' ] ?? true ;
383+ $ forcePkce = $ usePkce === 'force ' ;
384+ $ isPkceEnabled = $ forcePkce || ($ isPkceSupported && $ usePkce );
382385 $ usePrivateKeyJwt = $ this ->providerService ->getSetting ($ providerId , ProviderService::SETTING_USE_PRIVATE_KEY_JWT , '0 ' ) !== '0 ' ;
383386
384387 try {
0 commit comments