@@ -48,24 +48,9 @@ public function __construct(JtiValidator $jtiValidator)
4848 public function getWebId ($ request ) {
4949 $ serverParams = $ request ->getServerParams ();
5050
51- if (isset ($ serverParams ['HTTP_AUTHORIZATION ' ]) === false ) {
52- throw new AuthorizationHeaderException ("Authorization Header missing " );
53- }
54-
55- if (str_contains ($ serverParams ['HTTP_AUTHORIZATION ' ], ' ' ) === false ) {
56- throw new AuthorizationHeaderException ("Authorization Header does not contain parameters " );
57- }
51+ $ this ->validateRequestHeaders ($ serverParams );
5852
59- [$ authScheme , $ jwt ] = explode (" " , $ serverParams ['HTTP_AUTHORIZATION ' ], 2 );
60- $ authScheme = strtolower ($ authScheme );
61-
62- if ($ authScheme !== "dpop " ) {
63- throw new AuthorizationHeaderException ('Only "dpop" authorization scheme is supported ' );
64- }
65-
66- if (isset ($ serverParams ['HTTP_DPOP ' ]) === false ) {
67- throw new AuthorizationHeaderException ("Missing DPoP token " );
68- }
53+ [, $ jwt ] = explode (" " , $ serverParams ['HTTP_AUTHORIZATION ' ], 2 );
6954
7055 $ dpop = $ serverParams ['HTTP_DPOP ' ];
7156
@@ -287,4 +272,22 @@ private function getSubjectFromJwt($jwt) {
287272 }
288273 return $ sub ;
289274 }
275+
276+ private function validateRequestHeaders ($ serverParams ) {
277+ if (isset ($ serverParams ['HTTP_AUTHORIZATION ' ]) === false ) {
278+ throw new AuthorizationHeaderException ("Authorization Header missing " );
279+ }
280+
281+ if (str_contains ($ serverParams ['HTTP_AUTHORIZATION ' ], ' ' ) === false ) {
282+ throw new AuthorizationHeaderException ("Authorization Header does not contain parameters " );
283+ }
284+
285+ if (str_starts_with (strtolower ($ serverParams ['HTTP_AUTHORIZATION ' ]), 'dpop ' ) === false ) {
286+ throw new AuthorizationHeaderException ('Only "dpop" authorization scheme is supported ' );
287+ }
288+
289+ if (isset ($ serverParams ['HTTP_DPOP ' ]) === false ) {
290+ throw new AuthorizationHeaderException ("Missing DPoP token " );
291+ }
292+ }
290293}
0 commit comments