示例#1
0
 /**
  * Formats a response to send back to a client
  * 
  * @param int $code The TIF code to send back to the user
  * 
  * @return string
  */
 protected function formatResponse($code)
 {
     $resp = 'ver=' . implode(',', $this->config->getAcceptedVersions()) . "\r\n" . "nut=" . $this->sqrlGenerator->getNonce($code, $this->authenticationKey, $this->requestNut) . "\r\n" . 'tif=' . strtoupper(dechex($code)) . "\r\n" . "qry=" . $this->sqrlGenerator->generateQry() . "\r\n" . 'sfn=' . $this->config->getFriendlyName();
     if (!empty($this->ask)) {
         $resp .= "\r\nask=" . $this->ask;
     }
     if ($this->tif & self::SQRL_DISABLED && !in_array('lock', $this->actions)) {
         $resp .= "\r\nsuk=" . $this->base64UrlEncode($this->store->getIdentitySUK($this->authenticationKey));
     } elseif ($this->tif & self::PREVIOUS_ID_MATCH && !in_array('ident', $this->actions)) {
         $resp .= "\r\nsuk=" . $this->base64UrlEncode($this->store->getIdentitySUK($this->previousIdKey));
     }
     return $this->base64UrlEncode($resp);
 }
示例#2
0
 /**
  * Verifies the original nut's IP matches the current IP
  * 
  * @param string $nut
  * @param string $ip
  * 
  * @return boolean
  */
 public function nutIPMatches($nut, $ip)
 {
     $nutInfo = $this->store->getNutDetails($nut);
     return is_array($nutInfo) && $nutInfo['nutIP'] === $ip;
 }