[Pkg-owncloud-commits] [php-sabredav] 05/21: client add support for NTLM auth

David Prévot taffit at moszumanska.debian.org
Fri Jul 3 20:11:23 UTC 2015


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

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

commit 20f5bc7efc5cd451e5556394418dbc62ae555214
Author: Christoph Kappestein <christoph.kappestein at artemeon.de>
Date:   Tue Jun 16 16:47:52 2015 +0200

    client add support for NTLM auth
---
 lib/DAV/Client.php             | 12 ++++++++++--
 tests/Sabre/DAV/ClientTest.php | 13 +++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/lib/DAV/Client.php b/lib/DAV/Client.php
index 44b7e7e..3e6c2db 100644
--- a/lib/DAV/Client.php
+++ b/lib/DAV/Client.php
@@ -51,6 +51,11 @@ class Client extends HTTP\Client {
     const AUTH_DIGEST = 2;
 
     /**
+     * NTLM authentication
+     */
+    const AUTH_NTLM = 4;
+
+    /**
      * Identity encoding, which basically does not nothing.
      */
     const ENCODING_IDENTITY = 1;
@@ -90,8 +95,8 @@ class Client extends HTTP\Client {
      *   * authType (optional)
      *   * encoding (optional)
      *
-     *  authType must be a bitmap, using self::AUTH_BASIC and
-     *  self::AUTH_DIGEST. If you know which authentication method will be
+     *  authType must be a bitmap, using self::AUTH_BASIC, self::AUTH_DIGEST
+     *  and self::AUTH_NTLM. If you know which authentication method will be
      *  used, it's recommended to set it, as it will save a great deal of
      *  requests to 'discover' this information.
      *
@@ -125,6 +130,9 @@ class Client extends HTTP\Client {
                 if ($settings['authType'] & self::AUTH_DIGEST) {
                     $curlType |= CURLAUTH_DIGEST;
                 }
+                if ($settings['authType'] & self::AUTH_NTLM) {
+                    $curlType |= CURLAUTH_NTLM;
+                }
             } else {
                 $curlType = CURLAUTH_BASIC | CURLAUTH_DIGEST;
             }
diff --git a/tests/Sabre/DAV/ClientTest.php b/tests/Sabre/DAV/ClientTest.php
index 8e19c3f..e5504ae 100644
--- a/tests/Sabre/DAV/ClientTest.php
+++ b/tests/Sabre/DAV/ClientTest.php
@@ -68,6 +68,19 @@ class ClientTest extends \PHPUnit_Framework_TestCase {
 
     }
 
+    function testNTLMAuth() {
+
+        $client = new ClientMock([
+            'baseUri' => '/',
+            'userName' => 'foo',
+            'password' => 'bar',
+            'authType' => Client::AUTH_NTLM
+        ]);
+
+        $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]);
+        $this->assertEquals(CURLAUTH_NTLM, $client->curlSettings[CURLOPT_HTTPAUTH]);
+
+    }
 
     function testProxy() {
 

-- 
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