コード例 #1
0
 public function start(Request $request, AuthenticationException $authException = null)
 {
     $response = new Response();
     $response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', $this->realmName));
     $response->setStatusCode(401, $authException->getMessage());
     return $response;
 }
コード例 #2
0
 public function start(Request $request, AuthenticationException $authException = null)
 {
     $expiryTime = microtime(true) + $this->nonceValiditySeconds * 1000;
     $signatureValue = md5($expiryTime . ':' . $this->key);
     $nonceValue = $expiryTime . ':' . $signatureValue;
     $nonceValueBase64 = base64_encode($nonceValue);
     $authenticateHeader = sprintf('Digest realm="%s", qop="auth", nonce="%s"', $this->realmName, $nonceValueBase64);
     if ($authException instanceof NonceExpiredException) {
         $authenticateHeader = $authenticateHeader . ', stale="true"';
     }
     if (null !== $this->logger) {
         $this->logger->debug(sprintf('WWW-Authenticate header sent to user agent: "%s"', $authenticateHeader));
     }
     $response = new Response();
     $response->headers->set('WWW-Authenticate', $authenticateHeader);
     $response->setStatusCode(401, $authException->getMessage());
     return $response;
 }