From 33526e903d344bfc7a429b18189b6e4bbab97801 Mon Sep 17 00:00:00 2001 From: Sebastian Marcet Date: Mon, 22 Feb 2016 12:14:50 -0300 Subject: [PATCH] Fixed SSL redirect filter fixed ssl filter and added some config examples Change-Id: I90ab6d108e13d495dc12fde4fe8a4433b93a0a1f --- .env.example | 15 +++-- .env.testing | 52 --------------- app/Http/Kernel.php | 1 + app/Http/Middleware/SSLMiddleware.php | 36 +++++++++++ app/Http/routes.php | 8 +-- app/Providers/RouteServiceProvider.php | 88 ++++++++++---------------- config/server.php | 1 - 7 files changed, 85 insertions(+), 116 deletions(-) delete mode 100644 .env.testing create mode 100644 app/Http/Middleware/SSLMiddleware.php diff --git a/.env.example b/.env.example index 5bb339eb..c8817be2 100644 --- a/.env.example +++ b/.env.example @@ -41,12 +41,15 @@ CORS_USE_PRE_FLIGHT_CACHING=true CORS_MAX_AGE=3200 CORS_EXPOSED_HEADERS= -CURL_TIMEOUT=60 +CURL_TIMEOUT=3600 CURL_ALLOWS_REDIRECT=false -CURL_VERIFY_SSL_CERT=true +CURL_VERIFY_SSL_CERT=false -SSL_ENABLED=false -OAUTH2_ENABLED=true -DB_LOG_ENABLED=false ASSETS_BASE_URL=http://www.openstack.org -API_RESPONSE_CACHE_LIFETIME=10000 \ No newline at end of file +SSL_ENABLED=true +DB_LOG_ENABLED=true +ACCESS_TOKEN_CACHE_LIFETIME=300 +API_RESPONSE_CACHE_LIFETIME=600 + +LOG_EMAIL_TO=smarcet@gmail.com +LOG_EMAIL_FROM=smarcet@gmail.com \ No newline at end of file diff --git a/.env.testing b/.env.testing deleted file mode 100644 index ecb26bce..00000000 --- a/.env.testing +++ /dev/null @@ -1,52 +0,0 @@ -APP_ENV=testing -APP_DEBUG=true -APP_KEY=KKzP6APRNHmADURQ8OanDTU5kDpGwo6l -APP_URL=https://local.resource-server.openstack.org -APP_OAUTH_2_0_CLIENT_ID=tM9iYEq2iCP6P5WQL.~Zo2XXLbugpNhu.openstack.client -APP_OAUTH_2_0_CLIENT_SECRET=f70Ydbhq9NernTem4Yow8SEB -APP_OAUTH_2_0_AUTH_SERVER_BASE_URL=https://local.openstackid.openstack.org - -DB_HOST=localhost -DB_DATABASE=resource_server_test -DB_USERNAME=root -DB_PASSWORD=Koguryo@1981 - -SS_DB_HOST=localhost -SS_DATABASE=os_production2 -SS_DB_USERNAME=root -SS_DB_PASSWORD=Koguryo@1981 - -REDIS_HOST=127.0.0.1 -REDIS_PORT=6379 -REDIS_DB=0 -REDIS_PASSWORD= - -CACHE_DRIVER=redis - -SESSION_DRIVER=redis -SESSION_COOKIE_DOMAIN= -SESSION_COOKIE_SECURE=false - -QUEUE_DRIVER=sync - -MAIL_DRIVER=smtp -MAIL_HOST=mailtrap.io -MAIL_PORT=2525 -MAIL_USERNAME=null -MAIL_PASSWORD=null - - -LOG_EMAIL_TO= -LOG_EMAIL_FROM= - -CORS_ALLOWED_HEADERS=origin, content-type, accept, authorization, x-requested-with -CORS_ALLOWED_METHODS=GET, POST, OPTIONS, PUT, DELETE -CORS_USE_PRE_FLIGHT_CACHING=false -CORS_MAX_AGE=3200 -CORS_EXPOSED_HEADERS= - -CURL_TIMEOUT=3600 -CURL_ALLOWS_REDIRECT=false -CURL_VERIFY_SSL_CERT=false -DB_LOG_ENABLED=true -ASSETS_BASE_URL=http://www.openstack.org/ \ No newline at end of file diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 863aca71..5b280474 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -31,6 +31,7 @@ class Kernel extends HttpKernel 'rate.limit' => 'App\Http\Middleware\RateLimitMiddleware', 'etags' => 'App\Http\Middleware\ETagsMiddleware', 'cache' => 'App\Http\Middleware\CacheMiddleware', + 'ssl' => 'App\Http\Middleware\SSLMiddleware', ]; } \ No newline at end of file diff --git a/app/Http/Middleware/SSLMiddleware.php b/app/Http/Middleware/SSLMiddleware.php new file mode 100644 index 00000000..ea46dc14 --- /dev/null +++ b/app/Http/Middleware/SSLMiddleware.php @@ -0,0 +1,36 @@ + 'api/v1', - 'before' => ['ssl', 'oauth2.enabled'], - 'after' => '', - 'middleware' => ['oauth2.protected', 'rate.limit','etags'] + 'before' => [], + 'after' => [], + 'middleware' => ['ssl', 'oauth2.protected', 'rate.limit','etags'] ), function () { - Route::group(array('prefix' => 'marketplace'), function () { + Route::group(array('prefix' => 'marketplace'), function () { Route::group(array('prefix' => 'public-clouds'), function () { Route::get('', 'OAuth2PublicCloudApiController@getClouds'); diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 3a211e44..05e22c86 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -1,62 +1,44 @@ group(['namespace' => $this->namespace], function ($router) { - require app_path('Http/routes.php'); - }); - } + /** + * Define the routes for the application. + * @param \Illuminate\Routing\Router $router + * @return void + */ + public function map(Router $router) + { + $router->group(['namespace' => $this->namespace], function ($router) { + require app_path('Http/routes.php'); + }); + } } \ No newline at end of file diff --git a/config/server.php b/config/server.php index 6c8812f8..269e2a82 100644 --- a/config/server.php +++ b/config/server.php @@ -15,7 +15,6 @@ return array ( 'ssl_enabled' => env('SSL_ENABLED', false), - 'oauth2_enabled' => env('OAUTH2_ENABLED', true), 'db_log_enabled' => env('DB_LOG_ENABLED', false), 'access_token_cache_lifetime' => env('ACCESS_TOKEN_CACHE_LIFETIME', 300), 'assets_base_url' => env('ASSETS_BASE_URL', null),