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

Commit d508332

Browse files
author
Dominik František Bučík
authored
Merge pull request #249 from dBucik/consolidator_tool
feat: Consolidator tool
2 parents 80a67bc + e7bbde9 commit d508332

File tree

3 files changed

+80
-3
lines changed

3 files changed

+80
-3
lines changed

lib/Disco.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class Disco extends PowerIdPDisco
3333

3434
public const MFA_PROFILE = 'https://refeds.org/profile/mfa';
3535

36+
public const URN_CESNET_PROXYIDP_LSIDPENTITYID = 'urn:cesnet:proxyidp:lsidpentityid:';
37+
3638
// ROOT CONFIGURATION ENTRY
3739
public const WAYF = 'wayf_config';
3840

@@ -170,6 +172,8 @@ class Disco extends PowerIdPDisco
170172

171173
private $proxyIdpEntityId;
172174

175+
private $authId;
176+
173177
public function __construct(array $metadataSets, $instance)
174178
{
175179
//LOAD CONFIG FOR MODULE PERUN, WHICH CONTAINS WAYF CONFIGURATION
@@ -190,6 +194,7 @@ public function __construct(array $metadataSets, $instance)
190194

191195
if (isset($query[self::AUTH_ID])) {
192196
$id = explode(':', $query[self::AUTH_ID])[0];
197+
$this->authId = $id;
193198
$state = State::loadState($id, self::SAML_SP_SSO, true);
194199

195200
if (null !== $state) {
@@ -268,6 +273,26 @@ public function handleRequest()
268273
);
269274
HTTP::redirectTrustedURL($url);
270275
}
276+
$acrStartSubstr = substr($value, 0, strlen(self::URN_CESNET_PROXYIDP_LSIDPENTITYID));
277+
if (self::URN_CESNET_PROXYIDP_LSIDPENTITYID === $acrStartSubstr) {
278+
$hintIdpEntityId = substr(
279+
$value,
280+
strlen(self::URN_CESNET_PROXYIDP_LSIDPENTITYID),
281+
strlen($value)
282+
);
283+
$state = State::loadState($this->authId, self::SAML_SP_SSO, true);
284+
$state['aarc_idp_hint'] = $hintIdpEntityId;
285+
$id = State::saveState($state, self::SAML_SP_SSO);
286+
287+
Logger::info('Redirecting to LS AAI with hint to: ' . $hintIdpEntityId);
288+
$url = self::buildContinueUrl(
289+
$this->spEntityId,
290+
$this->returnURL,
291+
$this->returnIdParam,
292+
'https://proxy.aai.lifescience-ri.eu/proxy'
293+
);
294+
HTTP::redirectTrustedURL($url);
295+
}
271296
}
272297
}
273298
}
@@ -490,7 +515,7 @@ public static function showTaggedIdPs(DiscoTemplate $t, Configuration $blockConf
490515
if (0 === $idpCount) {
491516
return $html;
492517
}
493-
$html .= '<div class="row">' . PHP_EOL;
518+
$html .= '<div class="col-12 row">' . PHP_EOL;
494519
$html .= self::addLoginOptionHint($t, $blockConfig);
495520

496521
$counter = 0;
@@ -560,9 +585,9 @@ public static function showInlineSearch(
560585
$result .= '<div id="type-more" class="small text-muted">' . $t->t(
561586
'{perun:disco:search_start_hint}'
562587
) . '</div>' . PHP_EOL;
563-
$result .= '<div class="inlinesearch">' . PHP_EOL;
588+
$result .= '<div class="inlinesearch col-12">' . PHP_EOL;
564589
$result .= ' <form id="idpselectform" action="?" method="get">' . PHP_EOL;
565-
$result .= ' <input class="inlinesearch form-control input-lg" type="text" value=""
590+
$result .= ' <input class="inlinesearch form-control-lg" type="text" value=""
566591
name="query" id="query" autofocus placeholder="'
567592
. $t->t($placeholderTranslateKey) . '"/>' . PHP_EOL;
568593
$result .= ' </form>';

templates/consolidator-tpl.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Template of page, which showing status of used components.
7+
*/
8+
9+
use SimpleSAML\Configuration;
10+
11+
$config = Configuration::getInstance();
12+
$this->data['header'] = 'ELIXIR AAI account repair for Life Science Login';
13+
14+
$this->includeAtTemplateBase('includes/header.php');
15+
16+
$idpEntityId = $_GET['idpEntityId'];
17+
18+
//Check if value is allowed
19+
if (!filter_var($idpEntityId, FILTER_VALIDATE_URL)) {
20+
throw new Exception('ERROR');
21+
}
22+
23+
$consolidatorUrl = 'https://perun.elixir-czech.cz/lsaai-ic/ic/?targetIdP=' . urlencode($idpEntityId);
24+
$acrParam = 'urn:cesnet:proxyidp:lsidpentityid:' . $idpEntityId;
25+
//$acrParam = 'urn:cesnet:proxyidp:idpentityid:' . $idpEntityId;
26+
$url = 'https://perun.elixir-czech.cz/Consolidator.sso/Login?target=' . urlencode(
27+
$consolidatorUrl
28+
) . '&authnContextClassRef=' . urlencode($acrParam);
29+
30+
echo '
31+
<div>
32+
<p class="text-justify">You have been provided a special link, which will help us to prepare your account to be usable in the Life Science Login, to which your account will be migrated. You will now be asked to log in twice with your home organization. After that, your account should be ready to be used in Life Science Login.</p>
33+
<p class="text-justify">If you do not wish to use your home organization for login, let us know using the address below. In case of running into any issues, do not hesitate to contact us at <a href="mailto:[email protected]">[email protected]</a>.</p>
34+
<p>Proceed by clicking the button below.</p>
35+
<a href="' . $url . '">
36+
<div class="btn btn-primary btn-block">Continue</div>
37+
</a>
38+
</div>
39+
';
40+
41+
$this->includeAtTemplateBase('includes/footer.php');

www/consolidator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use SimpleSAML\Configuration;
6+
use SimpleSAML\XHTML\Template;
7+
8+
$config = Configuration::getInstance();
9+
10+
$t = new Template($config, 'perun:consolidator-tpl.php');
11+
$t->show();

0 commit comments

Comments
 (0)