示例#1
0
 public function testIs_authentication_required()
 {
     $_SERVER['REQUEST_URI'] = \BeeHub::USERS_PATH;
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $this->assertFalse(\BeeHub_Auth::is_authentication_required(), 'BeeHub_Auth::is_authentication_required() should return false when doing GET on the users collection (required to create a new user)');
     $_SERVER['REQUEST_METHOD'] = 'HEAD';
     $this->assertFalse(\BeeHub_Auth::is_authentication_required(), 'BeeHub_Auth::is_authentication_required() should return false when doing HEAD on the users collection (required to create a new user)');
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $this->assertFalse(\BeeHub_Auth::is_authentication_required(), 'BeeHub_Auth::is_authentication_required() should return false when doing POST on the users collection (required to create a new user)');
     $_SERVER['REQUEST_METHOD'] = 'PUT';
     $this->assertTrue(\BeeHub_Auth::is_authentication_required(), 'BeeHub_Auth::is_authentication_required() should return true when using another request method on the users collection (required to create a new user)');
     $_SERVER['REQUEST_URI'] = \BeeHub::SYSTEM_PATH;
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $this->assertFalse(\BeeHub_Auth::is_authentication_required(), 'BeeHub_Auth::is_authentication_required() should return false when doing GET on the system collection (required to read the homepage)');
     $_SERVER['REQUEST_METHOD'] = 'HEAD';
     $this->assertFalse(\BeeHub_Auth::is_authentication_required(), 'BeeHub_Auth::is_authentication_required() should return false when doing HEAD on the system collection (required to read the homepage)');
     $_SERVER['REQUEST_METHOD'] = 'PUT';
     $this->assertTrue(\BeeHub_Auth::is_authentication_required(), 'BeeHub_Auth::is_authentication_required() should return false when using another request method on the system collection (required to read the homepage)');
     $_SERVER['REQUEST_URI'] = '/some/other/path';
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $this->assertTrue(\BeeHub_Auth::is_authentication_required(), 'BeeHub_Auth::is_authentication_required() should return true on all other locations');
 }
示例#2
0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package BeeHub
 */
// Bootstrap the application
require_once '../src/beehub_bootstrap.php';
$config = BeeHub::config();
if (@$config['install']['run_install'] === 'true') {
    require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR . 'webserver_install.php';
    exit;
}
// If a GET request on the root doesn't have this server as a referer, redirect to the homepage:
if (!isset($_GET['nosystem']) && DAV::getPath() === '/' && $_SERVER['REQUEST_METHOD'] === 'GET' && (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['SERVER_NAME'] !== parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST))) {
    DAV::redirect(DAV::HTTP_SEE_OTHER, BeeHub::SYSTEM_PATH);
    return;
}
// After bootstrapping, start authentication
if (APPLICATION_ENV === BeeHub::ENVIRONMENT_TEST || !empty($_SERVER['HTTPS'])) {
    BeeHub_Auth::inst()->handle_authentication(BeeHub_Auth::is_authentication_required());
}
// And finally handle the request
$request = DAV_Request::inst();
if ($request) {
    $request->handleRequest();
}
// End of file