Explain token generation on the welcome page

Add token generation manual to the welcome page. Display example code
containing the current configuration dir, to generate tokens.

fixes #7408
This commit is contained in:
Matthias Jentsch 2014-10-28 17:32:49 +01:00
parent 2e8c0cffe6
commit b5468a122d
3 changed files with 95 additions and 93 deletions

View File

@ -14,12 +14,21 @@ use Icinga\Web\Form\Validator\TokenValidator;
*/
class WelcomePage extends Form
{
/**
* The configuration directory displayed to the user in the "generate security token" infobox
*
* @var string
*/
public $configDir = '/etc/icingaweb';
/**
* Initialize this page
*/
public function init()
{
$this->setName('setup_welcome');
$this->setViewScript('form/setup-welcome.phtml');
$this->configDir = preg_replace('_/$_', '', Icinga::app()->getConfigDir());
}
/**
@ -27,105 +36,15 @@ class WelcomePage extends Form
*/
public function createElements(array $formData)
{
$this->addElement(
new Note(
'welcome',
array(
'value' => t('Welcome to the installation of Icinga Web 2!'),
'decorators' => array(
'ViewHelper',
array('HtmlTag', array('tag' => 'h2'))
)
)
)
);
$this->addElement( // TODO: Remove this once we release the first public version
new Note(
'wip',
array(
'value' => 'Icinga Web 2 is still in development and not meant for production deployment.'
. ' Watch the <a href="https://dev.icinga.org/projects/icingaweb2/roadmap">development roadmap</a>'
. ' and <a href="https://www.icinga.org/">Icinga website</a> for release schedule updates!',
'decorators' => array(
'ViewHelper',
array(
'HtmlTag',
array(
'tag' => 'div',
'style' => 'border:1px solid #777;border-radius:1em;background-color:beige;'
. 'padding:1em;margin-bottom:1em;display:inline-block;'
)
)
)
)
)
);
$this->addElement(
new Note(
'description',
array(
'value' => sprintf(
t(
'Icinga Web 2 is the next generation monitoring web interface,'
. ' framework and CLI tool developed by the %s.'
),
'<a href="https://www.icinga.org/community/team/">' . t('Icinga Project') . '</a>'
)
)
)
);
$this->addElement(
new Note(
'facts',
array(
'value' => t(
'Responsive and fast, rewritten from scratch supporting multiple backends and'
. ' providing a CLI tool. Compatible with Icinga Core 2.x and 1.x.'
)
)
)
);
$this->addElement(
new Note(
'insights',
array(
'value' => sprintf(
t('Check the Icinga website for some %s.', 'setup.welcome.screenshots'),
'<a href="https://www.icinga.org/icinga/screenshots/icinga-web-2/">'
. t('insights', 'setup.welcome.screenshots.label') . '</a>'
)
)
)
);
$this->addDisplayGroup(
array('description', 'facts', 'insights'),
'info',
array(
'decorators' => array(
'FormElements',
array('HtmlTag', array('tag' => 'div', 'class' => 'info'))
)
)
);
$this->addElement(
new Note(
'purpose',
array(
'value' => t(
'This wizard will guide you through the installation of Icinga Web 2.'
. ' Once completed and successfully finished you are able to log in '
. 'and to explore all the new and stunning features!'
)
)
)
);
$this->addElement(
'text',
'token',
array(
'required' => true,
'label' => t('Setup Token'),
'description' => t('Please enter the setup token you\'ve created earlier by using the icingacli'),
'description' => t(
'For security reasons, we need to check that you are permitted to execute this setup. Please provide the token from the file "setup.token".'
),
'validators' => array(new TokenValidator(Icinga::app()->getConfigDir() . '/setup.token'))
)
);

View File

@ -0,0 +1,74 @@
<?php
use Icinga\Web\Wizard;
$setupToken = $this->form->configDir . '/setup.token';
?>
<form style="margin-top: 4em;" id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>" action="<?= $form->getAction(); ?>">
<h2><?= t('Welcome to the installation of Icinga Web 2!') ?></h2>
<!-- TODO: Remove this once we release the first public version -->
<div style="border:1px solid #777;border-radius:1em;background-color:beige;padding:1em;margin-bottom:1em;display:inline-block;">
Icinga Web 2 is still in development and not meant for production deployment.
Watch the <a href="https://dev.icinga.org/projects/icingaweb2/roadmap">development roadmap</a> and
<a href="https://www.icinga.org/">Icinga website</a> for release schedule updates!
</div>
<div class="info">
<p>
<?= sprintf(
t(
'Icinga Web 2 is the next generation monitoring web interface,'
. ' framework and CLI tool developed by the %s.'
),
'<a href="https://www.icinga.org/community/team/">' . t('Icinga Project') . '</a>'
); ?>
</p>
<p><?= t('Responsive and fast, rewritten from scratch supporting multiple backends and providing a CLI tool. ' .
' Compatible with Icinga Core 2.x and 1.x.') ?>
</p>
<p>
<?= sprintf(
t('Check the Icinga website for some %s.', 'setup.welcome.screenshots'),
'<a href="https://www.icinga.org/icinga/screenshots/icinga-web-2/">'
. t('insights', 'setup.welcome.screenshots.label') . '</a>'
) ?>
</p>
</div>
<p>
<?= t('This wizard will guide you through the installation of Icinga Web 2. Once completed and successfully ' .
'finished you are able to log in and to explore all the new and stunning features!') ?>
</p>
<?= $form->getElement('token') ?>
<?= $form->getElement($form->getTokenElementName()) ?>
<?= $form->getElement($form->getUidElementName()) ?>
<div class="buttons">
<?php
echo $form->getElement(Wizard::BTN_NEXT);
?>
</div>
<br>
</form>
<div style="border-radius: 0.2em; margin: auto; margin-top: 3em; text-align: center; max-width: 46em; border: 1px solid #eeeeee;">
<div style="border-radius: 0.2em; padding: 0.1em; background-color: #eeeeee; ">
<img style="float: right;" src="<?= $this->href('img/icons/comment.png') ?>"/>
Generating a new Security Token:
</div>
<div>
<p style="margin: 1em">
<?= t('As the Icinga Web 2 administrator you need set a security token, so the installer can authorize its user:') ?>
</p>
<span class="code"> sudo icingacli setup generateToken </span>
<p style="margin: 1em">
<?= t('If you don\'t have IcingaCLI available, you can set it yourself:') ?>
</p>
<span class="code">
head -c 12 /dev/urandom | base64 | sudo -u 'apache' tee <?= $setupToken ?>; <br/>
sudo chmod 0660 <?= $setupToken ?>; <br/>
</span> <br/>
<p>
<?= t('For further help, please check out the <a href="#">IcingaWeb2 Documentation</a> on this topic.') ?>
</p>
</div>
</div>

View File

@ -369,3 +369,12 @@
}
}
}
.code {
font-family: monospace;
display: inline-block;
padding: 1 1em;
border-radius: 1em;
min-width: 42em;
text-align: left;
}