implement authentication
[phancap.git] / www / get.php
index 6bb5c7f05cfdc9458e867c4403bf1e4f5b7d50b4..3d7395f057aaeb79989d1d09444cacdceb815b89 100644 (file)
@@ -13,7 +13,7 @@ if (file_exists(__DIR__ . '/../src/phancap/Autoloader.php')) {
 }
 
 $config = new Config();
-$config->setupCheck();
+$config->load();
 
 $options = new Options();
 try {
@@ -25,6 +25,16 @@ try {
     exit(1);
 }
 
+$auth = new Authenticator();
+try {
+    $auth->authenticate($config);
+} catch (\Exception $e) {
+    header('HTTP/1.0 401 Unauthorized');
+    header('Content-type: text/plain');
+    echo $e->getMessage() . "\n";
+    exit(1);
+}
+
 $rep = new Repository();
 $rep->setConfig($config);
 try {