Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --force flag to some artisan commands. #458

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions app/Tdt/Core/Proxy/ProxyServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Tdt\Core\Proxy;

use Illuminate\Support\ServiceProvider;

/**
* See http://fideloper.com/laravel-4-trusted-proxies
*/

class ProxyServiceProvider extends ServiceProvider {

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Register the service provider.
*
* @return void
*/
public function register() {
$request = $this->app['request'];
$proxies = $this->app['config']->get('proxy.proxies');

if( $proxies === '*' ) {
// Trust all proxies - proxy is whatever
// the current client IP address is
$proxies = array( $request->getClientIp() );
}
$request->setTrustedProxies( $proxies );
}

}
1 change: 1 addition & 0 deletions app/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
'Tdt\Core\Repositories\DbServiceProvider',
'Tdt\Core\Analytics\TrackerServiceProvider',
'Tdt\Input\InputServiceProvider',
'Tdt\Core\Proxy\ProxyServiceProvider',
),

/*
Expand Down
18 changes: 18 additions & 0 deletions app/config/proxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Trusted Proxies
|--------------------------------------------------------------------------
|
| Set an array of trusted proxies, so Laravel knows to grab the client's
| IP address via the HTTP_X_FORWARDED_FOR header.
|
| To trust all proxies, use the value '*':
|
| 'proxies' => '*'
|
*/

'proxies' => '*'
);
21 changes: 21 additions & 0 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@
|--------------------------------------------------------------------------
*/

/**
* First a hack that enables configuring TDT to live behind a proxy
*/

// we read a .env file as would be the case with Laravel 5
/*$env_file = dirname(__FILE__) . '/.env';

// parse this as properties defined in the .env file
$properties = parse_ini_file($env_file);

$proxy_url = $properties['PROXY_URL'];
$proxy_schema = $properties['PROXY_SCHEMA'];

if (!empty($proxy_url)) {
URL::forceRootUrl($proxy_url);
}

if (!empty($proxy_schema)) {
$proxy_schema = getenv('PROXY_SCHEMA');
}*/

/**
* Admin routes
*/
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"post-install-cmd": [
"php artisan optimize",
"php artisan migrate:install",
"php artisan migrate",
"php artisan migrate --package=cartalyst/sentry",
"php artisan db:seed",
"php artisan migrate --package=tdt/input",
"php artisan migrate --force",
"php artisan migrate --package=cartalyst/sentry --force",
"php artisan db:seed --force",
"php artisan migrate --package=tdt/input --force",
"php artisan asset:publish tdt/input",
"php artisan config:publish tdt/input"
],
Expand All @@ -53,8 +53,8 @@
],
"post-update-cmd": [
"php artisan optimize",
"php artisan migrate",
"php artisan migrate --package=cartalyst/sentry"
"php artisan migrate --force",
"php artisan migrate --package=cartalyst/sentry --force"
],
"post-create-project-cmd": [
"php artisan key:generate"
Expand Down