Skip to content
Snippets Groups Projects
Commit 45c1060a authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Adding a preproduction warning module.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1126 44740490-163a-0410-bde0-09ae8108e29a
parent 0219c515
No related branches found
No related tags found
No related merge requests found
<?php
$lang = array(
'warning' => array (
'no' => 'Du har nå kommet til et test-oppsett. Dette oppsettet for autentisering er kun til bruk for testing og pre-produksjon verifikasjon. Hvis noen sendte deg en link som pekte hit, og du ikke er <i>en tester</i> så fikk du nok en feil link, og <b>skulle ikke vært her</b>.',
'en' => 'You are now accessing a pre-production system. This authentication setup is for testing and pre-production verification only. If someone sent you a link that pointed you here, and you are not <i>a tester</i> you probably got the wrong link, and should <b>not be here</b>.',
),
'warning_header' => array (
'no' => 'Advarsel om at dette er et test oppsett',
'en' => 'Warning about accessing a pre-production system',
),
'yes' => array (
'no' => 'Ja, jeg holder på å teste innlogging, og vet dette er et test-system.',
'en' => 'Yes, I know I am accessing a pre-production system',
),
);
?>
\ No newline at end of file
<?php
/**
* Give a warning that the user is accessing a test system, not a production system.
*
* @package simpleSAMLphp
* @version $Id$
*/
class sspmod_preprodwarning_Auth_Process_Warning extends SimpleSAML_Auth_ProcessingFilter {
/**
* Process a authentication response.
*
* This function saves the state, and redirects the user to the page where the user
* can authorize the release of the attributes.
*
* @param array $state The state of the response.
*/
public function process(&$state) {
assert('is_array($state)');
assert('array_key_exists("UserID", $state)');
assert('array_key_exists("Destination", $state)');
assert('array_key_exists("entityid", $state["Destination"])');
assert('array_key_exists("metadata-set", $state["Destination"])');
assert('array_key_exists("entityid", $state["Source"])');
assert('array_key_exists("metadata-set", $state["Source"])');
/* Save state and redirect. */
$id = SimpleSAML_Auth_State::saveState($state, 'consent:request');
$url = SimpleSAML_Module::getModuleURL('preprodwarning/showwarning.php');
SimpleSAML_Utilities::redirect($url, array('StateId' => $id));
}
}
?>
\ No newline at end of file
<?php
/**
* Template form for giving consent.
*
* Parameters:
* - 'srcMetadata': Metadata/configuration for the source.
* - 'dstMetadata': Metadata/configuration for the destination.
* - 'yesTarget': Target URL for the yes-button. This URL will receive a POST request.
* - 'yesData': Parameters which should be included in the yes-request.
* - 'noTarget': Target URL for the no-button. This URL will receive a GET request.
* - 'noData': Parameters which should be included in the no-request.
* - 'attributes': The attributes which are about to be released.
* - 'sppp': URL to the privacy policy of the destination, or FALSE.
*
* @package simpleSAMLphp
* @version $Id$
*/
$this->data['header'] = $this->t('{preprodwarning:warning:warning_header}');
$this->includeAtTemplateBase('includes/header.php');
?>
<form style="display: inline; margin: 0px; padding: 0px" action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>">
<?php
// Embed hidden fields...
foreach ($this->data['yesData'] as $name => $value) {
echo('<input type="hidden" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars($value) . '" />');
}
?>
<p><?php echo $this->t('{preprodwarning:warning:warning}'); ?></p>
<input type="submit" name="yes" id="yesbutton" value="<?php echo htmlspecialchars($this->t('{preprodwarning:warning:yes}')) ?>" />
</form>
<?php
$this->includeAtTemplateBase('includes/footer.php');
?>
<?php
/**
* This script displays a page to the user, which requests that the user
* authorizes the release of attributes.
*
* @package simpleSAMLphp
* @version $Id$
*/
SimpleSAML_Logger::info('PreProdWarning - Showing warning to user');
if (!array_key_exists('StateId', $_REQUEST)) {
throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
}
$id = $_REQUEST['StateId'];
$state = SimpleSAML_Auth_State::loadState($id, 'consent:request');
if (array_key_exists('yes', $_REQUEST)) {
/* The user has pressed the yes-button. */
SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
}
$globalConfig = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'preprodwarning:warning.php');
$t->data['yesTarget'] = SimpleSAML_Module::getModuleURL('preprodwarning/showwarning.php');
$t->data['yesData'] = array('StateId' => $id);
$t->show();
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment