Skip to content

Commit f964a96

Browse files
committed
Added example for authenticating
Updated changelog
1 parent 25e8352 commit f964a96

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* Added: Added a very simple example for implementing a mapping to PHP
33
file streams. This should allow easy implementation of for example a
44
WebDAV to FTP proxy.
5+
* Added: HTTP Basic Authentication helper class.
6+
* Added: Sabre_HTTP_Reponse class. This centralizes HTTP operations and
7+
will be a start towards the creating of a testing framework.
58
* Updated: Backwards compatibility break: all require_once() statements
69
are removed
710
from all the files. It is now recommended to use autoloading of

examples/authenticating.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
// !!!! Make sure the Sabre directory is in the include_path !!!
4+
5+
// {$Id$} //
6+
7+
// settings
8+
date_default_timezone_set('Canada/Eastern');
9+
10+
// Files we need
11+
require_once 'Sabre.includes.php';
12+
13+
$u = 'admin';
14+
$p = '1234';
15+
16+
$auth = new Sabre_HTTP_BasicAuth();
17+
18+
$result = $auth->getUserPass();
19+
20+
if (!$result || $result[0]!=$u || $result[1]!=$p) {
21+
22+
$auth->requireLogin();
23+
echo "Authentication required\n";
24+
die();
25+
26+
}
27+
28+
?>

0 commit comments

Comments
 (0)