11<?php
2+
23declare (strict_types=1 );
34
45namespace chriskacerguis \RestServer \Filters ;
@@ -13,7 +14,7 @@ class AuthFilter implements FilterInterface
1314{
1415 public function before (RequestInterface $ request , $ arguments = null )
1516 {
16- $ config = config (RestConfig::class);
17+ $ config = config (RestConfig::class);
1718
1819 if ($ config ->auth === false || $ config ->auth === '' ) {
1920 // Auth disabled
@@ -163,15 +164,19 @@ private function findPasswordForUser(string $username, RestConfig $config): ?str
163164 return $ config ->validLogins [$ username ] ?? null ;
164165 }
165166
166- private function unauthorizedResponse (string $ scheme , string $ realm , string $ message = 'Unauthorized ' ): ResponseInterface
167- {
167+ private function unauthorizedResponse (
168+ string $ scheme ,
169+ string $ realm ,
170+ string $ message = 'Unauthorized '
171+ ): ResponseInterface {
168172 $ response = service ('response ' );
169173 if (!$ response instanceof ResponseInterface) {
170174 $ response = new Response (config ('App ' ));
171175 }
172176
173177 if ($ scheme === 'basic ' ) {
174- $ response ->setHeader ('WWW-Authenticate ' , 'Basic realm=" ' . addslashes ($ realm ) . '", charset="UTF-8" ' );
178+ $ basicHeader = 'Basic realm=" ' . addslashes ($ realm ) . '", charset="UTF-8" ' ;
179+ $ response ->setHeader ('WWW-Authenticate ' , $ basicHeader );
175180 } elseif ($ scheme === 'digest ' ) {
176181 $ nonce = bin2hex (random_bytes (16 ));
177182 $ opaque = bin2hex (random_bytes (16 ));
0 commit comments