@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | private function initTiqrLibrary() |
| 41 | 41 | { |
| 42 | 42 | // Initialise the tiqr-server-library autoloader |
| 43 | - $tiqr_dir = __DIR__ . '/../library/tiqr'; |
|
| 44 | - $vendor_dir = __DIR__ . '/../vendor'; |
|
| 43 | + $tiqr_dir = __DIR__.'/../library/tiqr'; |
|
| 44 | + $vendor_dir = __DIR__.'/../vendor'; |
|
| 45 | 45 | |
| 46 | - require_once $tiqr_dir . '/Tiqr/AutoLoader.php'; |
|
| 46 | + require_once $tiqr_dir.'/Tiqr/AutoLoader.php'; |
|
| 47 | 47 | |
| 48 | 48 | $autoloader = Tiqr_AutoLoader::getInstance([ |
| 49 | 49 | 'tiqr.path' => $tiqr_dir, |
| 50 | - 'phpqrcode.path' => $vendor_dir . '/kairos/phpqrcode', |
|
| 51 | - 'zend.path' => $vendor_dir . '/zendframework/zendframework1/library' |
|
| 50 | + 'phpqrcode.path' => $vendor_dir.'/kairos/phpqrcode', |
|
| 51 | + 'zend.path' => $vendor_dir.'/zendframework/zendframework1/library' |
|
| 52 | 52 | ]); |
| 53 | 53 | $autoloader->setIncludePath(); |
| 54 | 54 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | private function getStorageDir(): string |
| 60 | 60 | { |
| 61 | - $storage_dir = __DIR__ . '/storage'; |
|
| 61 | + $storage_dir = __DIR__.'/storage'; |
|
| 62 | 62 | if (!is_dir($storage_dir)) { |
| 63 | 63 | if (false == mkdir($storage_dir)) { |
| 64 | 64 | TestServerApp::error_exit(500, "Error creating storage directory: $storage_dir"); |
@@ -184,17 +184,17 @@ discard block |
||
| 184 | 184 | // The session ID is used for communicating enrollment status between this tiqr server and |
| 185 | 185 | // the web browser displaying the enrollment interface. It is not used between the tiqr client and |
| 186 | 186 | // this server. We do not use it. |
| 187 | - $session_id = 'session_id_' . time(); |
|
| 187 | + $session_id = 'session_id_'.time(); |
|
| 188 | 188 | $app::log_info("Created session $session_id"); |
| 189 | 189 | |
| 190 | 190 | // The user_id to create. Get it from the request, if it is not there use a test user ID. |
| 191 | - $user_id = $app->getGET()['user_id'] ?? 'test-user-' . time(); |
|
| 191 | + $user_id = $app->getGET()['user_id'] ?? 'test-user-'.time(); |
|
| 192 | 192 | |
| 193 | 193 | if ($this->userStorage->userExists($user_id)) { |
| 194 | 194 | $app::log_warning("$user_id already exists"); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - $user_display_name = $user_id . '\'s display name'; |
|
| 197 | + $user_display_name = $user_id.'\'s display name'; |
|
| 198 | 198 | |
| 199 | 199 | // Create enrollemnt key. The display name we set here is returned in the metadata generated by |
| 200 | 200 | // getEnrollmentMetadata. |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | // App differs from the user's displayname on the server. |
| 203 | 203 | $enrollment_key = $this->tiqrService->startEnrollmentSession($user_id, $user_display_name, $session_id); |
| 204 | 204 | $app::log_info("Started enrollment session $enrollment_key"); |
| 205 | - $metadataUrl = $this->host_url . "/metadata"; |
|
| 206 | - $enroll_string = $this->tiqrService->generateEnrollString($metadataUrl) . "?enrollment_key=$enrollment_key"; |
|
| 205 | + $metadataUrl = $this->host_url."/metadata"; |
|
| 206 | + $enroll_string = $this->tiqrService->generateEnrollString($metadataUrl)."?enrollment_key=$enrollment_key"; |
|
| 207 | 207 | $encoded_enroll_string = htmlentities(urlencode($enroll_string)); |
| 208 | - $image_url = "/qr?code=" . $encoded_enroll_string; |
|
| 208 | + $image_url = "/qr?code=".$encoded_enroll_string; |
|
| 209 | 209 | |
| 210 | 210 | $view->StartEnrollment(htmlentities($enroll_string), $image_url); |
| 211 | 211 | } |
@@ -247,8 +247,8 @@ discard block |
||
| 247 | 247 | // -----END NOTE----- |
| 248 | 248 | |
| 249 | 249 | // Add enrollment_secret to the $enrollment_url |
| 250 | - $enrollment_url = $this->host_url . "/finish-enrollment?enrollment_secret=$enrollment_secret"; |
|
| 251 | - $authentication_url = $this->host_url . '/authentication'; |
|
| 250 | + $enrollment_url = $this->host_url."/finish-enrollment?enrollment_secret=$enrollment_secret"; |
|
| 251 | + $authentication_url = $this->host_url.'/authentication'; |
|
| 252 | 252 | // Get the enrollment data |
| 253 | 253 | $enrollment_metadata = $this->tiqrService->getEnrollmentMetadata($enrollment_key, $authentication_url, $enrollment_url); |
| 254 | 254 | if (false == $enrollment_metadata) { |
@@ -365,10 +365,10 @@ discard block |
||
| 365 | 365 | private function logo(App $app) |
| 366 | 366 | { |
| 367 | 367 | // Source: https://nl.wikipedia.org/wiki/Bestand:Philips_PM5544.svg |
| 368 | - $name = __DIR__ . '/Philips_PM5544.jpg'; |
|
| 368 | + $name = __DIR__.'/Philips_PM5544.jpg'; |
|
| 369 | 369 | $fp = fopen($name, 'rb'); |
| 370 | 370 | header('Content-Type: image/jpeg'); |
| 371 | - header('Content-Length: ' . filesize($name)); |
|
| 371 | + header('Content-Length: '.filesize($name)); |
|
| 372 | 372 | fpassthru($fp); |
| 373 | 373 | fclose($fp); |
| 374 | 374 | } |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | $users = array(); |
| 380 | 380 | foreach (scandir($storageDir) as $filename) { |
| 381 | 381 | if (substr($filename, -5, 5) == '.json') { |
| 382 | - $user = json_decode(file_get_contents($storageDir . '/' . $filename), true); |
|
| 382 | + $user = json_decode(file_get_contents($storageDir.'/'.$filename), true); |
|
| 383 | 383 | if (($user != NULL) && ($user['secret'])) { |
| 384 | 384 | foreach ($user as $k => $v) { |
| 385 | 385 | $user[$k] = htmlentities($v); |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | private function start_authenticate(App $app, TestServerView $view) |
| 395 | 395 | { |
| 396 | - $session_id = 'session_id_' . time(); |
|
| 396 | + $session_id = 'session_id_'.time(); |
|
| 397 | 397 | $app::log_info("Created session $session_id"); |
| 398 | 398 | |
| 399 | 399 | // The user_id to authenticate. Get it from the request, if it is not there use an empty user ID |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | $app::log_info('Started authentication URL'); |
| 423 | 423 | $app::log_info("authentication_url=$authentication_URL"); |
| 424 | 424 | |
| 425 | - $image_url = "/qr?code=" . htmlentities(urlencode($authentication_URL)); |
|
| 425 | + $image_url = "/qr?code=".htmlentities(urlencode($authentication_URL)); |
|
| 426 | 426 | |
| 427 | 427 | $response = ''; |
| 428 | 428 | if (strlen($user_id) > 0) { |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | $app::log_info("secret=$secret"); |
| 433 | 433 | $exploded = explode('/', $authentication_URL); |
| 434 | 434 | $session_key = $exploded[3]; // hex encoded session |
| 435 | - $challenge = $exploded[4]; // 10 digit hex challenge |
|
| 435 | + $challenge = $exploded[4]; // 10 digit hex challenge |
|
| 436 | 436 | $app::log_info("challenge=$challenge"); |
| 437 | 437 | $ocra = new Tiqr_OCRAWrapper('OCRA-1:HOTP-SHA1-6:QH10-S'); |
| 438 | 438 | $response = $ocra->calculateResponse($secret, $challenge, $session_key); |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | // Lookup the secret of the user by ID |
| 521 | - $userSecret = $this->userStorage->getSecret($userId); // Assume this works |
|
| 521 | + $userSecret = $this->userStorage->getSecret($userId); // Assume this works |
|
| 522 | 522 | $app::log_info("userSercret=$userSecret"); |
| 523 | 523 | |
| 524 | 524 | $app::log_info("Authenticating user"); |
@@ -261,8 +261,7 @@ |
||
| 261 | 261 | foreach ($value1 as $key2 => $value2) { |
| 262 | 262 | $app::log_info("Metadata: $key1/$key2=$value2"); |
| 263 | 263 | } |
| 264 | - } |
|
| 265 | - else { |
|
| 264 | + } else { |
|
| 266 | 265 | $app::log_info("Metadata: $key1=$value1"); |
| 267 | 266 | } |
| 268 | 267 | } |
@@ -76,14 +76,14 @@ |
||
| 76 | 76 | if ($uri[0] != '/') { |
| 77 | 77 | self::error_exit(500, 'REQUEST_URI must start with "/"'); |
| 78 | 78 | } |
| 79 | - self::log_info('--'); // End of the HTTP dump |
|
| 79 | + self::log_info('--'); // End of the HTTP dump |
|
| 80 | 80 | |
| 81 | 81 | $path = parse_url($uri, PHP_URL_PATH); |
| 82 | 82 | |
| 83 | 83 | try { |
| 84 | 84 | $this->router->Route($this, $path); |
| 85 | 85 | } catch (Exception $e) { |
| 86 | - self::error_exit(500, 'Exception: ' . $e->getMessage() . "\n\n" . $e->getTraceAsString()); |
|
| 86 | + self::error_exit(500, 'Exception: '.$e->getMessage()."\n\n".$e->getTraceAsString()); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $refreshurl = '/start-authenticate'; |
| 98 | 98 | if (strlen($user_id) > 0) { |
| 99 | - $refreshurl.= "?user_id=$user_id"; |
|
| 99 | + $refreshurl .= "?user_id=$user_id"; |
|
| 100 | 100 | } |
| 101 | 101 | $this->begin(); |
| 102 | 102 | echo <<<HTML |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | <code>$authentication_URL</code> |
| 108 | 108 | <br /> |
| 109 | 109 | HTML; |
| 110 | - if (strlen($response)>0) { |
|
| 110 | + if (strlen($response) > 0) { |
|
| 111 | 111 | echo <<<HTML |
| 112 | 112 | <p>The response (for offline validation) is: <code>$response</code></p> |
| 113 | 113 | HTML; |
@@ -14,18 +14,18 @@ |
||
| 14 | 14 | |
| 15 | 15 | namespace TestServer; |
| 16 | 16 | |
| 17 | -require_once __DIR__ . '/TestServerApp.php'; |
|
| 18 | -require_once __DIR__ . '/TestServerController.php'; |
|
| 19 | -require_once __DIR__ . '/TestServerView.php'; |
|
| 17 | +require_once __DIR__.'/TestServerApp.php'; |
|
| 18 | +require_once __DIR__.'/TestServerController.php'; |
|
| 19 | +require_once __DIR__.'/TestServerView.php'; |
|
| 20 | 20 | |
| 21 | 21 | // TODO: Update / set configuration. See readme |
| 22 | 22 | $config_filename = 'config'; |
| 23 | 23 | |
| 24 | -$config_dir = __DIR__ . '/config/'; |
|
| 24 | +$config_dir = __DIR__.'/config/'; |
|
| 25 | 25 | |
| 26 | 26 | $config = array(); |
| 27 | -if (file_exists($config_dir . $config_filename)) { |
|
| 28 | - $config = json_decode(file_get_contents($config_dir . $config_filename), true); |
|
| 27 | +if (file_exists($config_dir.$config_filename)) { |
|
| 28 | + $config = json_decode(file_get_contents($config_dir.$config_filename), true); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $host_url = $config['host_url'] ?? 'http://localhost:8000'; |