@@ -61,14 +61,12 @@ public function getLoginFormData(ServerRequestInterface $request)
6161 );
6262 }
6363
64- $ authorizationHeader = $ request ->getHeader ('authorization ' )[0 ]
65- ?? $ request ->getHeader ('redirect_http_authorization ' )[0 ]
66- ?? '' ;
64+ $ authorizationHeader = $ this ->resolveAuthorizationHeader ($ request );
6765
6866 [$ scheme , $ authorizationData ] = GeneralUtility::trimExplode (' ' , $ authorizationHeader , true );
6967
7068 if ($ scheme === null ) {
71- throw new InvalidArgumentException (
69+ throw new UnauthorizedAccessException (
7270 'No authorization scheme provided. ' ,
7371 $ request
7472 );
@@ -109,9 +107,7 @@ public function getLoginFormData(ServerRequestInterface $request)
109107 */
110108 protected function authenticateBearerToken (ServerRequestInterface $ request ): void
111109 {
112- $ authorizationHeader = $ request ->getHeader ('authorization ' )[0 ]
113- ?? $ request ->getHeader ('redirect_http_authorization ' )[0 ]
114- ?? '' ;
110+ $ authorizationHeader = $ this ->resolveAuthorizationHeader ($ request );
115111
116112 [$ scheme , $ token ] = GeneralUtility::trimExplode (' ' , $ authorizationHeader , true );
117113
@@ -154,4 +150,19 @@ protected function getAuthServiceConfiguration(): array
154150
155151 return $ configuration ;
156152 }
153+
154+ /**
155+ * @param ServerRequestInterface $request
156+ * @return string
157+ * @throws UnauthorizedAccessException if no authorization scheme is provided.
158+ */
159+ protected function resolveAuthorizationHeader (ServerRequestInterface $ request ): string
160+ {
161+ return $ request ->getHeader ('authorization ' )[0 ]
162+ ?? $ request ->getHeader ('redirect_http_authorization ' )[0 ]
163+ ?? throw new UnauthorizedAccessException (
164+ 'No authorization scheme provided. ' ,
165+ $ request
166+ );
167+ }
157168}
0 commit comments