@@ -906,6 +906,16 @@ private function getBackchannelLogoutErrorResponse(
906906 );
907907 }
908908
909+ private function toCodeChallenge (string $ data ): string {
910+ // Basically one big work around for the base64url decode being weird
911+ $ h = pack ('H* ' , hash ('sha256 ' , $ data ));
912+ $ s = base64_encode ($ h ); // Regular base64 encoder
913+ $ s = explode ('= ' , $ s )[0 ]; // Remove any trailing '='s
914+ $ s = str_replace ('+ ' , '- ' , $ s ); // 62nd char of encoding
915+ $ s = str_replace ('/ ' , '_ ' , $ s ); // 63rd char of encoding
916+ return $ s ;
917+ }
918+
909919 private function isMobileDevice (): bool {
910920 $ mobileKeywords = $ this ->config ->getSystemValue ('user_oidc.mobile_keywords ' , ['Android ' , 'iPhone ' , 'iPad ' , 'iPod ' , 'Windows Phone ' , 'Mobile ' , 'webOS ' , 'BlackBerry ' , 'Opera Mini ' , 'IEMobile ' ]);
911921
@@ -921,14 +931,4 @@ private function isMobileDevice(): bool {
921931
922932 return false ; // device is desktop
923933 }
924-
925- private function toCodeChallenge (string $ data ): string {
926- // Basically one big work around for the base64url decode being weird
927- $ h = pack ('H* ' , hash ('sha256 ' , $ data ));
928- $ s = base64_encode ($ h ); // Regular base64 encoder
929- $ s = explode ('= ' , $ s )[0 ]; // Remove any trailing '='s
930- $ s = str_replace ('+ ' , '- ' , $ s ); // 62nd char of encoding
931- $ s = str_replace ('/ ' , '_ ' , $ s ); // 63rd char of encoding
932- return $ s ;
933- }
934934}
0 commit comments