HEX
Server: LiteSpeed
System: Linux d8 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: wbwebdes (3015)
PHP: 8.1.31
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/wbwebdes/domains/files.wb-cloud.nl/public_html/3rdparty/sabre/http/lib/Auth/Bearer.php
<?php

declare(strict_types=1);

namespace Sabre\HTTP\Auth;

/**
 * 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'
 *
 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
 * @author François Kooman ([email protected])
 * @license http://sabre.io/license/ Modified BSD License
 */
class Bearer extends AbstractAuth
{
    /**
     * This method returns a string with an access token.
     *
     * If no token was found, this method returns null.
     *
     * @return string|null
     */
    public function getToken()
    {
        $auth = $this->request->getHeader('Authorization');

        if (!$auth) {
            return null;
        }

        if ('bearer ' !== strtolower(substr($auth, 0, 7))) {
            return null;
        }

        return substr($auth, 7);
    }

    /**
     * This method sends the needed HTTP header and status code (401) to force
     * authentication.
     */
    public function requireLogin()
    {
        $this->response->addHeader('WWW-Authenticate', 'Bearer realm="'.$this->realm.'"');
        $this->response->setStatus(401);
    }
}