ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\HTTP\Auth\Bearer Class Reference

HTTP Bearer authentication utility. More...

+ Inheritance diagram for Sabre\HTTP\Auth\Bearer:
+ Collaboration diagram for Sabre\HTTP\Auth\Bearer:

Public Member Functions

 getToken ()
 This method returns a string with an access token. More...
 
 requireLogin ()
 This method sends the needed HTTP header and statuscode (401) to force authentication. More...
 
- Public Member Functions inherited from Sabre\HTTP\Auth\AbstractAuth
 __construct ($realm='SabreTooth', RequestInterface $request, ResponseInterface $response)
 Creates the object. More...
 
 requireLogin ()
 This method sends the needed HTTP header and statuscode (401) to force the user to login. More...
 
 getRealm ()
 Returns the HTTP realm. More...
 

Additional Inherited Members

- Protected Attributes inherited from Sabre\HTTP\Auth\AbstractAuth
 $realm
 
 $request
 
 $response
 

Detailed Description

HTTP Bearer authentication utility.

This class helps you setup bearer auth. The process is fairly simple:

  1. Instantiate the class.
  2. Call getToken (this will return null or a token as string)
  3. If you didn't get a valid token, call 'requireLogin'
Author
François Kooman (fkoom.nosp@m.an@t.nosp@m.uxed..nosp@m.net) http://sabre.io/license/ Modified BSD License

Definition at line 18 of file Bearer.php.

Member Function Documentation

◆ getToken()

Sabre\HTTP\Auth\Bearer::getToken ( )

This method returns a string with an access token.

If no token was found, this method returns null.

Returns
null|string

Definition at line 27 of file Bearer.php.

References $auth.

27  {
28 
29  $auth = $this->request->getHeader('Authorization');
30 
31  if (!$auth) {
32  return null;
33  }
34 
35  if (strtolower(substr($auth, 0, 7)) !== 'bearer ') {
36  return null;
37  }
38 
39  return substr($auth, 7);
40 
41  }
$auth
Definition: fileserver.php:48

◆ requireLogin()

Sabre\HTTP\Auth\Bearer::requireLogin ( )

This method sends the needed HTTP header and statuscode (401) to force authentication.

Returns
void

Definition at line 49 of file Bearer.php.

49  {
50 
51  $this->response->addHeader('WWW-Authenticate', 'Bearer realm="' . $this->realm . '"');
52  $this->response->setStatus(401);
53 
54  }

The documentation for this class was generated from the following file: