安全认证

This commit is contained in:
候学杰 2019-01-25 19:01:53 +08:00
parent ebb71df16f
commit 5051bf2434
3 changed files with 21 additions and 2 deletions

View File

@ -45,9 +45,15 @@ class Security
} }
if (Str::startsWith($ip, [ if (Str::startsWith($ip, [
'127.0.0.', '127.0.0.1',
//局域网
'192.168.', '192.168.',
//vpc
'10.0.', '10.0.',
//pod network
'172.20.',
//北京办公区
'172.16.'
])) { ])) {
return true; return true;
} }

View File

@ -3,14 +3,26 @@
namespace JsonRpc\Providers; namespace JsonRpc\Providers;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use JsonRpc\Exception\RpcServerException;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Monolog\Logger; use Monolog\Logger;
class BaseServiceProvider extends ServiceProvider class BaseServiceProvider extends ServiceProvider
{ {
public function boot(){
Request::setTrustedProxies([
//pod network
'172.20.0.0/16',
//vpc
'10.0.2.0/16',
//local
'127.0.0.1',
//北京办公区
'172.16.100.0/16'
], Request::HEADER_X_FORWARDED_ALL);
}
protected function setupConfig() protected function setupConfig()
{ {

View File

@ -25,6 +25,7 @@ class LumenServerServiceProvider extends BaseServiceProvider
public function boot() public function boot()
{ {
parent::boot();
$this->app->middleware(TunnelMiddleware::class); $this->app->middleware(TunnelMiddleware::class);
$this->app->routeMiddleware(['rpc.security' => Security::class]); $this->app->routeMiddleware(['rpc.security' => Security::class]);
$this->app->router->group([ $this->app->router->group([