ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AbstractBearer.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV\Auth\Backend;
4 
5 use Sabre\DAV;
6 use Sabre\HTTP;
9 
23 abstract class AbstractBearer implements BackendInterface {
24 
33  protected $realm = 'sabre/dav';
34 
44  abstract protected function validateBearerToken($bearerToken);
45 
52  function setRealm($realm) {
53 
54  $this->realm = $realm;
55 
56  }
57 
87 
88  $auth = new HTTP\Auth\Bearer(
89  $this->realm,
90  $request,
91  $response
92  );
93 
94  $bearerToken = $auth->getToken($request);
95  if (!$bearerToken) {
96  return [false, "No 'Authorization: Bearer' header found. Either the client didn't send one, or the server is mis-configured"];
97  }
98  $principalUrl = $this->validateBearerToken($bearerToken);
99  if (!$principalUrl) {
100  return [false, "Bearer token was incorrect"];
101  }
102  return [true, $principalUrl];
103 
104  }
105 
128 
129  $auth = new HTTP\Auth\Bearer(
130  $this->realm,
131  $request,
132  $response
133  );
134  $auth->requireLogin();
135 
136  }
137 
138 }
This interface represents a HTTP response.
The RequestInterface represents a HTTP request.
foreach($paths as $path) $request
Definition: asyncclient.php:32
challenge(RequestInterface $request, ResponseInterface $response)
This method is called when a user could not be authenticated, and authentication was required for the...
HTTP Bearer authentication utility.
Definition: Bearer.php:18
validateBearerToken($bearerToken)
Validates a Bearer token.
$auth
Definition: fileserver.php:48
check(RequestInterface $request, ResponseInterface $response)
When this method is called, the backend must check if authentication was successful.
HTTP Bearer authentication backend class.
This is the base class for any authentication object.
$response
setRealm($realm)
Sets the authentication realm for this backend.