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

Commit e96b0c1

Browse files
committed
feat: don't sign in user automatically
Show page with description and sign in button if user is not authenticated. Allow user to log out.
1 parent 94f888f commit e96b0c1

File tree

4 files changed

+81
-36
lines changed

4 files changed

+81
-36
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
{
2+
"header": {
3+
"en": "Attribute conformance",
4+
"cs": "Kontrola atributů"
5+
},
26
"show_hide_btn": {
37
"en": "Show / Hide all attributes",
48
"cs": "Zobrazit / Skrýt všechny atributy"
9+
},
10+
"sign_in_text": {
11+
"en": "Welcome to the service for verifying Identity Provider conformance. This service will help you configure your Identity Provider (or report to its administrator) the status of meeting the requirements to work with the AAI. <br/> Hit the sign-in button below to initiate the login process. By doing so, you will have to select the Identity Provider, which you want to use for login. After authenticating with your credentials, you will be presented with status information, describing if the requirements have been met or not.",
12+
"cs": "Vítejte na službě pro ověření kompatibility Vašeho poskytovatele identit. Tato služba Vám pomůže při konfiguraci Identity Providera splnit požadavky AAI. <br/> Pokračujte tlačítkem Přihlásit se na výběr poskytovatele identit. Po přihlášení Vám bude zobrazen stav kompatibility s AAI."
13+
},
14+
"sign_in_btn": {
15+
"en": "Sign in",
16+
"cs": "Přihlásit se"
17+
},
18+
"log_out_btn": {
19+
"en": "Log out",
20+
"cs": "Odhlásit se"
521
}
622
}

templates/attribute_check-tpl.php

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
*
1111
* @var SimpleSAML\XHTML\Template $this
1212
*/
13-
$attributes = $this->data['attributes'];
14-
$attributesGroupConfiguration = $this->data['attributes_group_config'];
1513

14+
$attributesGroupConfiguration = $this->data['attributes_group_config'];
15+
$as = $this->data['as'];
1616

1717
$this->data['header'] = '';
1818
$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' .
@@ -25,43 +25,69 @@
2525

2626
$this->includeAtTemplateBase('includes/header.php');
2727

28-
foreach ($attributesGroupConfiguration as $group) {
29-
echo AttributeCheck::handleAttributesGroup($this, $group, $attributes);
28+
echo "<h1>" . $this->t('{attribute_check:attribute_check:header}') . "</h1>";
29+
30+
if (!$as->isAuthenticated()){
31+
echo "<div class='mt-5'>";
32+
echo "<div>" . $this->t('{attribute_check:attribute_check:sign_in_text}') . "</div>";
33+
echo sprintf(
34+
"<a class='btn btn-primary text-light mt-5' href='%s'>%s</a>",
35+
$as->getLoginURL(),
36+
$this->t('{attribute_check:attribute_check:sign_in_btn}')
37+
);
38+
echo "</div>";
3039
}
3140

32-
?>
33-
<div>
34-
<button class="btn btn-primary btn-show-hide" type="button" data-bs-toggle="collapse" data-bs-target="#all_attributes" aria-expanded="false" aria-controls="all_attributes">
35-
<?php
36-
echo $this->t('{attribute_check:attribute_check:show_hide_btn}');
37-
?>
38-
</button>
39-
</div>
40-
<?php
41+
if ($as->isAuthenticated()){
42+
$attributes = $as->getAttributes();
4143

42-
echo "<div class='collapse attributes_block' id='all_attributes'>";
43-
foreach ($attributes as $attributeName => $attributeValue) {
44-
echo "<div class='row attribute_row'>";
45-
echo "<div class='col-md-4 attribute_name'>";
46-
echo '<div>' . $attributeName . '</div>';
47-
echo '</div>';
44+
foreach ($attributesGroupConfiguration as $group) {
45+
echo AttributeCheck::handleAttributesGroup($this, $group, $attributes);
46+
}
47+
48+
?>
49+
<div>
50+
<button aria-controls="all_attributes" aria-expanded="false" class="btn btn-primary btn-show-hide"
51+
data-bs-target="#all_attributes" data-bs-toggle="collapse" type="button">
52+
<?php
53+
echo $this->t('{attribute_check:attribute_check:show_hide_btn}');
54+
?>
55+
</button>
56+
</div>
57+
<?php
4858

49-
echo "<div class='col-md-8 attribute_value'>";
50-
if (count($attributeValue) > 1) {
51-
echo '<ul>';
52-
foreach ($attributeValue as $value) {
53-
echo '<li>' . $value . '</li>';
59+
echo "<div class='collapse attributes_block' id='all_attributes'>";
60+
foreach ($attributes as $attributeName => $attributeValue) {
61+
echo "<div class='row attribute_row'>";
62+
echo "<div class='col-md-4 attribute_name'>";
63+
echo '<div>' . $attributeName . '</div>';
64+
echo '</div>';
65+
66+
echo "<div class='col-md-8 attribute_value'>";
67+
if (count($attributeValue) > 1) {
68+
echo '<ul>';
69+
foreach ($attributeValue as $value) {
70+
echo '<li>' . $value . '</li>';
71+
}
72+
echo '</ul>';
73+
} elseif (count($attributeValue) === 1) {
74+
echo '<div>' . $attributeValue[0] . '</div>';
75+
} else {
76+
echo '<div></div>';
5477
}
55-
echo '</ul>';
56-
} elseif (count($attributeValue) === 1) {
57-
echo '<div>' . $attributeValue[0] . '</div>';
58-
} else {
59-
echo '<div></div>';
60-
}
6178

79+
echo '</div>';
80+
echo '</div>';
81+
}
6282
echo '</div>';
63-
echo '</div>';
6483
}
65-
echo '</div>';
84+
85+
if ($as->isAuthenticated()){
86+
echo sprintf(
87+
"<a class='btn btn-light text-dark' href='%s'>%s</a>",
88+
$as->getLogoutURL(),
89+
$this->t('{attribute_check:attribute_check:log_out_btn}')
90+
);
91+
}
6692

6793
$this->includeAtTemplateBase('includes/footer.php');

www/attribute_check.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
const CONFIG_FILE_NAME = 'config_attribute_check.php';
1616

1717
$as = new Simple('default-sp');
18-
$as->requireAuth();
19-
$attributes = $as->getAttributes();
2018

2119
$config = Configuration::getInstance();
2220
$conf = Configuration::getConfig(CONFIG_FILE_NAME);
@@ -25,5 +23,5 @@
2523

2624
$t = new Template($config, 'attribute_check:attribute_check-tpl.php');
2725
$t->data['attributes_group_config'] = $attributesGroupConfiguration;
28-
$t->data['attributes'] = $attributes;
26+
$t->data['as'] = $as;
2927
$t->show();

www/res/css/attribute_check.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ body, .btn {
2222
word-break: break-word;
2323
}
2424

25-
.btn-show-hide {
25+
.btn {
2626
margin: 25px 10%;
2727
width: 80%;
2828
padding: 10px 25px;
2929
font-weight: bold;
30+
color: white;
31+
}
32+
33+
a:link {
34+
font-weight: bold;
3035
}

0 commit comments

Comments
 (0)