request->getHeader('Authorization'); if (!$auth) { return null; } if (strtolower(substr($auth, 0, 7)) !== 'bearer ') { return null; } return substr($auth, 7); } /** * This method sends the needed HTTP header and statuscode (401) to force * authentication. * * @return void */ function requireLogin() { $this->response->addHeader('WWW-Authenticate', 'Bearer realm="' . $this->realm . '"'); $this->response->setStatus(401); } }