From 9105c45ad0ca8ca881954debeef1c43f6d044578 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 17 Dec 2017 01:10:49 -0600 Subject: [PATCH] Convert .env file to env.php to mask critical info --- .htaccess | 40 ++++++++++++++++ bootstrap/application.php | 2 +- env.php | 46 +++++++++++++++++++ .env.example => env.php.example | 0 modules/Installer/Config/config.php | 2 +- .../Installer/Services/EnvironmentService.php | 4 +- public/.htaccess | 5 ++ public/index.php | 4 -- 8 files changed, 95 insertions(+), 8 deletions(-) create mode 100755 .htaccess create mode 100644 env.php rename .env.example => env.php.example (100%) diff --git a/.htaccess b/.htaccess new file mode 100755 index 00000000..0ff7906a --- /dev/null +++ b/.htaccess @@ -0,0 +1,40 @@ +# Disable index view +Options -Indexes + +# Hide a specific file + + Order allow,deny + Deny from all + + + + Order allow,deny + Deny from all + + +# Hide a specific file + + Order allow,deny + Deny from all + + + + + Options -MultiViews + + + RewriteEngine On + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)/$ /$1 [L,R=301] + + # Handle Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + + # Handle Authorization Header + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + diff --git a/bootstrap/application.php b/bootstrap/application.php index e5da982f..e2c422fc 100644 --- a/bootstrap/application.php +++ b/bootstrap/application.php @@ -18,7 +18,7 @@ class Application extends LaravelApplication { parent::__construct(dirname(__DIR__) . '/'); - $this->loadEnvironmentFrom('.env'); + $this->loadEnvironmentFrom('env.php'); $this->useDatabasePath($this->basePath . '/app/Database'); $this->useStoragePath($this->basePath . '/storage'); } diff --git a/env.php b/env.php new file mode 100644 index 00000000..b9e9efde --- /dev/null +++ b/env.php @@ -0,0 +1,46 @@ + + +# +# Before you go live, remember to change the APP_ENV to production +# and APP_DEBUG to false. Adjust logging to taste +# + +APP_ENV=dev +APP_URL=http://localhost +APP_SKIN=default +APP_KEY=base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY= +APP_DEBUG=true +APP_LOCALE=en + +PHPVMS_INSTALLED=true +VACENTRAL_API_KEY= + +APP_LOG=daily +APP_LOG_LEVEL=debug +APP_LOG_MAX_FILES=3 + +DB_CONNECTION=sqlite +#DB_CONNECTION=mysql +DB_HOST=localhost +DB_PORT=3306 +DB_DATABASE=phpvms +DB_USERNAME=root +DB_PASSWORD= +DB_PREFIX= + +MAIL_DRIVER=smtp +MAIL_FROM_ADDRESS=no-reply@phpvms.net +MAIL_FROM_NAME="phpVMS Admin" +MAIL_HOST=smtp.mailgun.org +MAIL_PORT=587 +MAIL_ENCRYPTION=tls +MAIL_USERNAME= +MAIL_PASSWORD= + +CACHE_DRIVER=file +CACHE_PREFIX= + +SESSION_DRIVER=file +QUEUE_DRIVER=database diff --git a/.env.example b/env.php.example similarity index 100% rename from .env.example rename to env.php.example diff --git a/modules/Installer/Config/config.php b/modules/Installer/Config/config.php index 76ea37af..7c70537c 100644 --- a/modules/Installer/Config/config.php +++ b/modules/Installer/Config/config.php @@ -5,7 +5,7 @@ return [ 'version' => '7.0.0' ], - 'env_postfix' => '', + 'env_filename' => 'env.php', 'extensions' => [ 'openssl', diff --git a/modules/Installer/Services/EnvironmentService.php b/modules/Installer/Services/EnvironmentService.php index d0a06fa5..a0334316 100644 --- a/modules/Installer/Services/EnvironmentService.php +++ b/modules/Installer/Services/EnvironmentService.php @@ -86,8 +86,8 @@ class EnvironmentService */ protected function writeEnvFile($opts) { - $env_file = \App::environmentFilePath(); - $env_file .= config('installer.env_postfix'); + $env_file = \App::environmentPath(); + $env_file .= config('installer.env_filename'); # render it within Blade and log the contents $env_contents = view('installer::stubs/env', $opts); diff --git a/public/.htaccess b/public/.htaccess index 6d41d87d..0ff7906a 100755 --- a/public/.htaccess +++ b/public/.htaccess @@ -7,6 +7,11 @@ Options -Indexes Deny from all + + Order allow,deny + Deny from all + + # Hide a specific file Order allow,deny diff --git a/public/index.php b/public/index.php index 40a1ed5a..fdb2ec1c 100755 --- a/public/index.php +++ b/public/index.php @@ -14,11 +14,7 @@ $path_to_phpvms_folder = __DIR__.'/../'; require $path_to_phpvms_folder.'/bootstrap/autoload.php'; -/** - * @var $app Illuminate\Foundation\Application - */ $app = require_once $path_to_phpvms_folder.'/bootstrap/app.php'; - $app->setPublicPath(__DIR__); $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);