From 20bad68845343f630a0f2ccde6d540c604c63e63 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 12 Aug 2013 13:08:14 +0200 Subject: [PATCH] Added SSL option to web and cli installers --- install.php | 21 +++++++++++++++++++++ lib/installer.php | 7 ++++++- scripts/install_cli.php | 7 ++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index f44999285a..3fc0a8ab02 100644 --- a/install.php +++ b/install.php @@ -27,6 +27,7 @@ * @author Craig Andrews * @author Eric Helgeson * @author Evan Prodromou + * @author Mikael Nordfeldth * @author Robin Millette * @author Sarven Capadisli * @author Tom Adams @@ -168,6 +169,13 @@ class WebInstaller extends Installer } } + $ssl = array('always'=>null, 'never'=>null); + if (!empty($_SERVER['HTTPS'])) { + $ssl['always'] = 'checked="checked"'; + } else { + $ssl['never'] = 'checked="checked"'; + } + echo<<
@@ -185,6 +193,12 @@ class WebInstaller extends Installer disable

Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.

+
  • + + enable
    + disable
    +

    Enabling SSL (https://) requires extra webserver configuration and certificate generation not offered by this installation.

    +
  • @@ -321,6 +335,8 @@ STR; $this->siteProfile = $post->string('site_profile'); + $this->ssl = $post->string('ssl'); + $this->server = $_SERVER['HTTP_HOST']; $this->path = substr(dirname($_SERVER['PHP_SELF']), 1); @@ -338,6 +354,11 @@ STR; $fail = true; } + if (!in_array($this->ssl, array('never', 'sometimes', 'always'))) { + $this->updateStatus("Bad value for server SSL enabling."); + $fail = true; + } + if (!$this->validateSiteProfile()) { $fail = true; } diff --git a/lib/installer.php b/lib/installer.php index 2fe83dd9a2..69ad194829 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -28,6 +28,7 @@ * @author Craig Andrews * @author Eric Helgeson * @author Evan Prodromou + * @author Mikael Nordfeldth * @author Robin Millette * @author Sarven Capadisli * @author Tom Adams @@ -42,7 +43,7 @@ abstract class Installer { /** Web site info */ - public $sitename, $server, $path, $fancy, $siteProfile; + public $sitename, $server, $path, $fancy, $siteProfile, $ssl; /** DB info */ public $host, $database, $dbtype, $username, $password, $db; /** Administrator info */ @@ -412,6 +413,9 @@ abstract class Installer 'sitename' => $this->sitename, 'server' => $this->server, 'path' => $this->path, + 'ssl' => in_array($this->ssl, array('never', 'sometimes', 'always')) + ? $this->ssl + : 'never', 'db_database' => $this->db['database'], 'db_type' => $this->db['type'] )); @@ -426,6 +430,7 @@ abstract class Installer // site location "\$config['site']['server'] = {$vals['server']};\n". "\$config['site']['path'] = {$vals['path']}; \n\n". + "\$config['site']['ssl'] = {$vals['ssl']}; \n\n". // checks if fancy URLs are enabled ($this->fancy ? "\$config['site']['fancy'] = true;\n\n":''). diff --git a/scripts/install_cli.php b/scripts/install_cli.php index 3e18f28f3e..acdc38fabe 100755 --- a/scripts/install_cli.php +++ b/scripts/install_cli.php @@ -21,8 +21,9 @@ * @package Installation * * @author Brion Vibber + * @author Mikael Nordfeldth * @license GNU Affero General Public License http://www.gnu.org/licenses/ - * @version 0.9.x + * @version 1.1.x * @link http://status.net */ @@ -72,6 +73,7 @@ class CliInstaller extends Installer '--path' => 'path', '--sitename' => 'sitename', '--fancy' => 'fancy', + '--ssl' => 'ssl', '--dbtype' => 'dbtype', '--host' => 'host', @@ -106,6 +108,7 @@ class CliInstaller extends Installer $this->dbtype = 'mysql'; $this->adminUpdates = true; $this->verbose = true; + // ssl is defaulted in lib/installer.php foreach ($options as $option) { $arg = $option[0]; @@ -159,6 +162,8 @@ install_cli.php - StatusNet command-line installer -p --path= Use as path name --sitename User-friendly site name (required) --fancy Whether to use fancy URLs (default no) + --ssl Server SSL enabled (default never), + [never | sometimes | always] --dbtype 'mysql' (default) or 'pgsql' --host Database hostname (required)