[Pkg-owncloud-commits] [php-sabredav] 12/80: remove the principal prefix for Bearer token

David Prévot taffit at moszumanska.debian.org
Thu Jan 7 02:56:16 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit f3f89d5008d14e28f7419b6f7bbb50fe00d8d77d
Author: François Kooman <fkooman at tuxed.net>
Date:   Wed Sep 2 15:23:20 2015 +0200

    remove the principal prefix for Bearer token
---
 lib/DAV/Auth/Backend/AbstractBearer.php             | 19 ++++++-------------
 tests/Sabre/DAV/Auth/Backend/AbstractBearerTest.php |  2 +-
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/lib/DAV/Auth/Backend/AbstractBearer.php b/lib/DAV/Auth/Backend/AbstractBearer.php
index dfa2279..6bc10b7 100644
--- a/lib/DAV/Auth/Backend/AbstractBearer.php
+++ b/lib/DAV/Auth/Backend/AbstractBearer.php
@@ -33,20 +33,13 @@ abstract class AbstractBearer implements BackendInterface {
     protected $realm = 'sabre/dav';
 
     /**
-     * This is the prefix that will be used to generate principal urls.
-     *
-     * @var string
-     */
-    protected $principalPrefix = 'principals/';
-
-    /**
      * Validates a Bearer token
      *
-     * This method should return true or false depending on if login
-     * succeeded.
+     * This method should return the full principal url, or false if the 
+     * token was incorrect.
      *
      * @param string $bearerToken
-     * @return bool
+     * @return string|false
      */
     abstract protected function validateBearerToken($bearerToken);
 
@@ -102,11 +95,11 @@ abstract class AbstractBearer implements BackendInterface {
         if (!$bearerToken) {
             return [false, "No 'Authorization: Bearer' header found. Either the client didn't send one, or the server is mis-configured"];
         }
-        $resourceOwner = $this->validateBearerToken($bearerToken);
-        if (!$resourceOwner) {
+        $principalUrl = $this->validateBearerToken($bearerToken);
+        if (!$principalUrl) {
             return [false, "Bearer token was incorrect"];
         }
-        return [true, $this->principalPrefix . $resourceOwner];
+        return [true, $principalUrl];
 
     }
 
diff --git a/tests/Sabre/DAV/Auth/Backend/AbstractBearerTest.php b/tests/Sabre/DAV/Auth/Backend/AbstractBearerTest.php
index bb850b5..76aae74 100644
--- a/tests/Sabre/DAV/Auth/Backend/AbstractBearerTest.php
+++ b/tests/Sabre/DAV/Auth/Backend/AbstractBearerTest.php
@@ -84,7 +84,7 @@ class AbstractBearerMock extends AbstractBearer {
      */
     function validateBearerToken($bearerToken) {
 
-        return 'valid' === $bearerToken ? 'username' : false;
+        return 'valid' === $bearerToken ? 'principals/username' : false;
 
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list