コード例 #1
0
ファイル: DigestAuthTest.php プロジェクト: TamirAl/hubzilla
 public function testDigestApacheEdgeCase()
 {
     list($nonce, $opaque) = $this->getServerTokens();
     $username = '******';
     $password = 12345;
     $nc = '00002';
     $cnonce = uniqid();
     $digestHash = md5(md5($username . ':' . self::REALM . ':' . $password) . ':' . $nonce . ':' . $nc . ':' . $cnonce . ':' . 'auth:' . md5('GET' . ':' . '/'));
     $request = new Request(array('REQUEST_METHOD' => 'GET', 'REDIRECT_HTTP_AUTHORIZATION' => 'Digest username="******", realm="' . self::REALM . '", nonce="' . $nonce . '", uri="/", response="' . $digestHash . '", opaque="' . $opaque . '", qop=auth,nc=' . $nc . ',cnonce="' . $cnonce . '"'));
     $this->auth->setHTTPRequest($request);
     $this->auth->init();
     $this->assertTrue($this->auth->validateA1(md5($username . ':' . self::REALM . ':' . $password)), 'Authentication is deemed invalid through validateA1');
     $this->assertTrue($this->auth->validatePassword($password), 'Authentication is deemed invalid through validatePassword');
 }
コード例 #2
0
ファイル: digestauth.php プロジェクト: TamirAl/hubzilla
<?php

// !!!! Make sure the Sabre directory is in the include_path !!!
// example:
// set_include_path('lib/' . PATH_SEPARATOR . get_include_path());
// settings
date_default_timezone_set('Canada/Eastern');
// Files we need
require_once 'vendor/autoload.php';
$u = 'admin';
$p = '1234';
$auth = new \Sabre\HTTP\DigestAuth();
$auth->init();
if ($auth->getUsername() != $u || !$auth->validatePassword($p)) {
    $auth->requireLogin();
    echo "Authentication required\n";
    die;
}