Skip to content

Instantly share code, notes, and snippets.

@shalaby
Forked from PavelPolyakov/filters.php
Created June 23, 2014 08:07
Show Gist options
  • Save shalaby/dd7be8ec89e014659bdd to your computer and use it in GitHub Desktop.
Save shalaby/dd7be8ec89e014659bdd to your computer and use it in GitHub Desktop.
<?php
// located in the /app/filters.php
/* some original code */
Route::filter('statistics.auth.basic', function() {
$user = Request::getUser();
$password = Request::getPassword();
if (!App::environment('development') &&
(
(!$user || !$password) ||
($user != Config::get('statistics-auth-basic.user') || $password != Config::get('statistics-auth-basic.password')
)) {
$response = Response::make('Not authorized', 401);
$response->header('WWW-Authenticate', 'Basic realm="statistics"');
return $response;
}
});
/* some original code */
<?php
// located in the /app/config/statistics-auth-basic.php
return array(
'user' => 'user',
'password' => 'password'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment