summaryrefslogtreecommitdiff
path: root/api/httpauth.inc.php
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2007-12-12 16:29:16 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2007-12-12 16:29:16 +0000
commitd582054c77b22daeb08d2bff17794b9a69a20dd4 (patch)
treed6e7cef8639da6f573cd0b21a5316abf5af24fac /api/httpauth.inc.php
downloadsemanticscuttle-d582054c77b22daeb08d2bff17794b9a69a20dd4.tar.gz
semanticscuttle-d582054c77b22daeb08d2bff17794b9a69a20dd4.tar.bz2
import of scuttle 0.7.2
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@1 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'api/httpauth.inc.php')
-rw-r--r--api/httpauth.inc.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/api/httpauth.inc.php b/api/httpauth.inc.php
new file mode 100644
index 0000000..bc26582
--- /dev/null
+++ b/api/httpauth.inc.php
@@ -0,0 +1,22 @@
+<?php
+// Provides HTTP Basic authentication of a user, and sets two variables, sId and username,
+// with the user's info.
+
+function authenticate() {
+ header('WWW-Authenticate: Basic realm="del.icio.us API"');
+ header('HTTP/1.0 401 Unauthorized');
+ die("Use of the API calls requires authentication.");
+}
+
+if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ authenticate();
+} else {
+ require_once('../header.inc.php');
+ $userservice =& ServiceFactory::getServiceInstance('UserService');
+
+ $login = $userservice->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
+ if (!$login) {
+ authenticate();
+ }
+}
+?> \ No newline at end of file