aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/http/lib/Auth/Bearer.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
committerredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
commit0b02a6d123b2014705998c94ddf3d460948d3eac (patch)
tree78ff2cab9944a4f5ab3f80ec93cbe1120de90bb2 /vendor/sabre/http/lib/Auth/Bearer.php
parent40b5b6e9d2da7ab65c8b4d38cdceac83a4d78deb (diff)
downloadvolse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.gz
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.bz2
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.zip
initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import)
Diffstat (limited to 'vendor/sabre/http/lib/Auth/Bearer.php')
-rw-r--r--vendor/sabre/http/lib/Auth/Bearer.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/vendor/sabre/http/lib/Auth/Bearer.php b/vendor/sabre/http/lib/Auth/Bearer.php
new file mode 100644
index 000000000..eefdf11ee
--- /dev/null
+++ b/vendor/sabre/http/lib/Auth/Bearer.php
@@ -0,0 +1,56 @@
+<?php
+
+namespace Sabre\HTTP\Auth;
+
+/**
+ * HTTP Bearer authentication utility.
+ *
+ * This class helps you setup bearer auth. The process is fairly simple:
+ *
+ * 1. Instantiate the class.
+ * 2. Call getToken (this will return null or a token as string)
+ * 3. If you didn't get a valid token, call 'requireLogin'
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author François Kooman (fkooman@tuxed.net)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Bearer extends AbstractAuth {
+
+ /**
+ * This method returns a string with an access token.
+ *
+ * If no token was found, this method returns null.
+ *
+ * @return null|string
+ */
+ function getToken() {
+
+ $auth = $this->request->getHeader('Authorization');
+
+ if (!$auth) {
+ return null;
+ }
+
+ if (strtolower(substr($auth, 0, 7)) !== 'bearer ') {
+ return null;
+ }
+
+ return substr($auth, 7);
+
+ }
+
+ /**
+ * This method sends the needed HTTP header and statuscode (401) to force
+ * authentication.
+ *
+ * @return void
+ */
+ function requireLogin() {
+
+ $this->response->addHeader('WWW-Authenticate', 'Bearer realm="' . $this->realm . '"');
+ $this->response->setStatus(401);
+
+ }
+
+}