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

Commit

Permalink
feat: don't sign in user automatically
Browse files Browse the repository at this point in the history
Show page with description and sign in button if user is not authenticated.
Allow user to log out.
  • Loading branch information
vyskocilpavel committed Oct 29, 2021
1 parent 94f888f commit 10a8f12
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 36 deletions.
16 changes: 16 additions & 0 deletions dictionaries/attribute_check.definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{
"header": {
"en": "Attribute conformance",
"cs": "Kontrola atributů"
},
"show_hide_btn": {
"en": "Show / Hide all attributes",
"cs": "Zobrazit / Skrýt všechny atributy"
},
"sign_in_text": {
"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.",
"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."
},
"sign_in_btn": {
"en": "Sign in",
"cs": "Přihlásit se"
},
"log_out_btn": {
"en": "Log out",
"cs": "Odhlásit se"
}
}
87 changes: 55 additions & 32 deletions templates/attribute_check-tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*
* @var SimpleSAML\XHTML\Template $this
*/
$attributes = $this->data['attributes'];
$attributesGroupConfiguration = $this->data['attributes_group_config'];

$attributesGroupConfiguration = $this->data['attributes_group_config'];
$as = $this->data['as'];

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

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

foreach ($attributesGroupConfiguration as $group) {
echo AttributeCheck::handleAttributesGroup($this, $group, $attributes);
echo '<h1>' . $this->t('{attribute_check:attribute_check:header}') . '</h1>';

if (! $as->isAuthenticated()) {
echo "<div class='mt-5'>";
echo '<div>' . $this->t('{attribute_check:attribute_check:sign_in_text}') . '</div>';
echo sprintf(
"<a class='btn btn-primary text-light mt-5' href='%s'>%s</a>",
$as->getLoginURL(),
$this->t('{attribute_check:attribute_check:sign_in_btn}')
);
echo '</div>';
}

?>
<div>
<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">
<?php
echo $this->t('{attribute_check:attribute_check:show_hide_btn}');
?>
</button>
</div>
<?php
if ($as->isAuthenticated()) {
$attributes = $as->getAttributes();

echo "<div class='collapse attributes_block' id='all_attributes'>";
foreach ($attributes as $attributeName => $attributeValue) {
echo "<div class='row attribute_row'>";
echo "<div class='col-md-4 attribute_name'>";
echo '<div>' . $attributeName . '</div>';
echo '</div>';
foreach ($attributesGroupConfiguration as $group) {
echo AttributeCheck::handleAttributesGroup($this, $group, $attributes);
} ?>
<div>
<button aria-controls="all_attributes" aria-expanded="false" class="btn btn-primary btn-show-hide"
data-bs-target="#all_attributes" data-bs-toggle="collapse" type="button">
<?php
echo $this->t('{attribute_check:attribute_check:show_hide_btn}'); ?>
</button>
</div>
<?php

echo "<div class='collapse attributes_block' id='all_attributes'>";
foreach ($attributes as $attributeName => $attributeValue) {
echo "<div class='row attribute_row'>";
echo "<div class='col-md-4 attribute_name'>";
echo '<div>' . $attributeName . '</div>';
echo '</div>';

echo "<div class='col-md-8 attribute_value'>";
if (count($attributeValue) > 1) {
echo '<ul>';
foreach ($attributeValue as $value) {
echo '<li>' . $value . '</li>';
echo "<div class='col-md-8 attribute_value'>";
if (count($attributeValue) > 1) {
echo '<ul>';
foreach ($attributeValue as $value) {
echo '<li>' . $value . '</li>';
}
echo '</ul>';
} elseif (count($attributeValue) === 1) {
echo '<div>' . $attributeValue[0] . '</div>';
} else {
echo '<div></div>';
}
echo '</ul>';
} elseif (count($attributeValue) === 1) {
echo '<div>' . $attributeValue[0] . '</div>';
} else {
echo '<div></div>';
}

echo '</div>';
echo '</div>';
}
echo '</div>';
echo '</div>';
}
echo '</div>';

if ($as->isAuthenticated()) {
echo sprintf(
"<a class='btn btn-light text-dark' href='%s'>%s</a>",
$as->getLogoutURL(),
$this->t('{attribute_check:attribute_check:log_out_btn}')
);
}

$this->includeAtTemplateBase('includes/footer.php');
4 changes: 1 addition & 3 deletions www/attribute_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
const CONFIG_FILE_NAME = 'config_attribute_check.php';

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

$config = Configuration::getInstance();
$conf = Configuration::getConfig(CONFIG_FILE_NAME);
Expand All @@ -25,5 +23,5 @@

$t = new Template($config, 'attribute_check:attribute_check-tpl.php');
$t->data['attributes_group_config'] = $attributesGroupConfiguration;
$t->data['attributes'] = $attributes;
$t->data['as'] = $as;
$t->show();
7 changes: 6 additions & 1 deletion www/res/css/attribute_check.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ body, .btn {
word-break: break-word;
}

.btn-show-hide {
.btn {
margin: 25px 10%;
width: 80%;
padding: 10px 25px;
font-weight: bold;
color: white;
}

a:link {
font-weight: bold;
}

0 comments on commit 10a8f12

Please sign in to comment.