Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 8687a65

Browse files
committed
Filter which shows warnining for test SPs.
Test SP must have test.sp = true parameter in metadata.
1 parent 22872a1 commit 8687a65

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

lib/Auth/Process/WarningTestSP.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/**
4+
* Class sspmod_perun_Auth_Process_WarningTestSP
5+
*
6+
* Warns user that he/she is accessing to the testing SP
7+
*/
8+
class sspmod_perun_Auth_Process_WarningTestSP extends SimpleSAML_Auth_ProcessingFilter
9+
{
10+
11+
public function __construct($config, $reserved)
12+
{
13+
parent::__construct($config, $reserved);
14+
}
15+
public function process(&$request)
16+
{
17+
if ($request["SPMetadata"]["test.sp"] === true) {
18+
$id = SimpleSAML_Auth_State::saveState($request, 'perun:warningTestSP');
19+
$url = SimpleSAML_Module::getModuleURL('perun/warning_test_sp_page.php');
20+
\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
21+
}
22+
}
23+
24+
}
25+

templates/warning-test-sp-tpl.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* Template for warn user that he/she is accessing test SP
5+
*
6+
* Allow type hinting in IDE
7+
* @var SimpleSAML_XHTML_Template $this
8+
*/
9+
10+
$this->data['header'] = '';
11+
12+
$this->includeAtTemplateBase('includes/header.php');
13+
14+
?>
15+
16+
17+
<form method="post" action="<?php echo SimpleSAML_Module::getModuleURL('perun/warning_test_sp_continue.php'); ?>" >
18+
19+
<input type="hidden" name="StateId" value="<?php echo $_REQUEST['StateId'] ?>" >
20+
<h3>You are about to access service, which is in testing environment.</h3>
21+
</hr>
22+
</br>
23+
24+
<div class="form-group">
25+
<input type="submit" value="Continue" class="btn btn-lg btn-primary btn-block">
26+
</div>
27+
</form>
28+
29+
30+
31+
<?php
32+
33+
$this->includeAtTemplateBase('includes/footer.php');

www/warning_test_sp_page.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
$id = $_REQUEST['StateId'];
4+
$state = SimpleSAML_Auth_State::loadState($id, 'perun:warningTestSP');
5+
6+
$config = SimpleSAML_Configuration::getInstance();
7+
8+
$t = new SimpleSAML_XHTML_Template($config, 'perun:warning-test-sp-tpl.php');
9+
$t->show();
10+

0 commit comments

Comments
 (0)