ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
digestauth.php
Go to the documentation of this file.
1
<?
php
2
10
$userList
= [
11
"user1"
=>
"password"
,
12
"user2"
=>
"password"
,
13
];
14
15
use
Sabre\HTTP\Auth
;
16
use
Sabre\HTTP\Response
;
17
use
Sabre\HTTP\Sapi
;
18
19
// Find the autoloader
20
$paths
= [
21
__DIR__ .
'/../vendor/autoload.php'
,
22
__DIR__ .
'/../../../autoload.php'
,
23
__DIR__ .
'/vendor/autoload.php'
,
24
25
];
26
27
foreach
(
$paths
as
$path
) {
28
if
(file_exists(
$path
)) {
29
include
$path
;
30
break
;
31
}
32
}
33
34
$request
= Sapi::getRequest();
35
$response
=
new
Response
();
36
37
$digestAuth
=
new
Auth\Digest(
"Locked down area"
,
$request
,
$response
);
38
$digestAuth
->init();
39
if
(!$userName =
$digestAuth
->getUsername()) {
40
41
// No username given
42
$digestAuth
->requireLogin();
43
44
} elseif (!isset(
$userList
[$userName]) || !
$digestAuth
->validatePassword(
$userList
[$userName])) {
45
46
// Username or password are incorrect
47
$digestAuth
->requireLogin();
48
}
else
{
49
50
// Success !
51
$response
->setBody(
'You are logged in!'
);
52
53
}
54
55
// Sending the response
56
Sapi::sendResponse(
$response
);
$path
$path
Definition:
aliased.php:25
php
An exception for terminatinating execution or to throw for unit testing.
Sabre\HTTP\Response
This class represents a single HTTP response.
Definition:
Response.php:12
Sabre\HTTP\Sapi
PHP SAPI.
Definition:
Sapi.php:31
$paths
$paths
Definition:
digestauth.php:20
$request
foreach($paths as $path) $request
Definition:
digestauth.php:34
$userList
$userList
This example shows how to do Digest authentication.
Definition:
digestauth.php:10
$digestAuth
$digestAuth
Definition:
digestauth.php:37
$response
$response
Definition:
digestauth.php:35
Sabre\HTTP\Auth
Definition:
AbstractAuth.php:3
libs
composer
vendor
sabre
http
examples
digestauth.php
Generated on Thu Oct 2 2025 19:01:16 for ILIAS by
1.9.4 (using
Doxyfile
)