@@ -149,7 +149,10 @@ public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
149149 * @NoCSRFRequired
150150 * @NoSameSiteCookieRequired
151151 */
152- public function grantPage (string $ stateToken ): StandaloneTemplateResponse {
152+ public function grantPage (?string $ stateToken ): StandaloneTemplateResponse {
153+ if ($ stateToken === null ) {
154+ return $ this ->stateTokenMissingResponse ();
155+ }
153156 if (!$ this ->isValidStateToken ($ stateToken )) {
154157 return $ this ->stateTokenForbiddenResponse ();
155158 }
@@ -181,7 +184,11 @@ public function grantPage(string $stateToken): StandaloneTemplateResponse {
181184 /**
182185 * @PublicPage
183186 */
184- public function apptokenRedirect (string $ stateToken , string $ user , string $ password ) {
187+ public function apptokenRedirect (?string $ stateToken , string $ user , string $ password ) {
188+ if ($ stateToken === null ) {
189+ return $ this ->stateTokenMissingResponse ();
190+ }
191+
185192 if (!$ this ->isValidStateToken ($ stateToken )) {
186193 return $ this ->stateTokenForbiddenResponse ();
187194 }
@@ -224,7 +231,10 @@ public function apptokenRedirect(string $stateToken, string $user, string $passw
224231 * @NoAdminRequired
225232 * @UseSession
226233 */
227- public function generateAppPassword (string $ stateToken ): Response {
234+ public function generateAppPassword (?string $ stateToken ): Response {
235+ if ($ stateToken === null ) {
236+ return $ this ->stateTokenMissingResponse ();
237+ }
228238 if (!$ this ->isValidStateToken ($ stateToken )) {
229239 return $ this ->stateTokenForbiddenResponse ();
230240 }
@@ -297,6 +307,19 @@ private function isValidStateToken(string $stateToken): bool {
297307 return hash_equals ($ currentToken , $ stateToken );
298308 }
299309
310+ private function stateTokenMissingResponse (): StandaloneTemplateResponse {
311+ $ response = new StandaloneTemplateResponse (
312+ $ this ->appName ,
313+ '403 ' ,
314+ [
315+ 'message ' => $ this ->l10n ->t ('State token missing ' ),
316+ ],
317+ 'guest '
318+ );
319+ $ response ->setStatus (Http::STATUS_FORBIDDEN );
320+ return $ response ;
321+ }
322+
300323 private function stateTokenForbiddenResponse (): StandaloneTemplateResponse {
301324 $ response = new StandaloneTemplateResponse (
302325 $ this ->appName ,
0 commit comments