Skip to content

Commit

Permalink
add serviceName validation (Merge pull request #178 from salvorapi/fi…
Browse files Browse the repository at this point in the history
…x-issue-177)

add serviceName validation
  • Loading branch information
damikael authored Oct 11, 2022
2 parents 63e2e85 + f7883aa commit caeb5ed
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"config": {
"version": "3.10.2"
"version": "3.10.3",
"allow-plugins": {
"simplesamlphp/composer-module-installer": true
}
},
"repositories": {
"spid-sp-access-button": {
Expand Down
41 changes: 29 additions & 12 deletions setup/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,21 @@ public static function setup(Event $event) {
}

if (!isset($config['serviceName'])) {
echo "Please insert name for service endpoint (" .
$colors->getColoredString($_serviceName, "green") . "): ";
$config['serviceName'] = str_replace("'", "\'", readline());
if ($config['serviceName'] == null || $config['serviceName'] == "") {
$config['serviceName'] = $_serviceName;
}
do {
echo "Please insert name for service endpoint (" .
$colors->getColoredString($_serviceName, "green") . "): ";
$serviceName = readline();
if ($serviceName == null || $serviceName == "") {
$serviceName = $_serviceName;
break;
}
$is_valid = preg_match("/^\w{1}[-\w]*$/i", $serviceName);
if (!$is_valid)
echo "Value '{$serviceName}' not allowed\n";

} while(!$is_valid);
$config['serviceName'] = $serviceName;

}

if (!isset($config['entityID'])) {
Expand Down Expand Up @@ -1310,12 +1319,20 @@ public static function remove() {
if (!empty($config['serviceName'])) {
$serviceName = $config['serviceName'];
} else {
echo "Please insert name for service endpoint (" .
$colors->getColoredString($_serviceName, "green") . "): ";
$serviceName = readline();
if ($serviceName == null || $serviceName == "") {
$serviceName = $_serviceName;
}
do {
echo "Please insert name for service endpoint (" .
$colors->getColoredString($_serviceName, "green") . "): ";
$serviceName = readline();
if ($serviceName == null || $serviceName == "") {
$serviceName = $_serviceName;
break;
}
$is_valid = preg_match("/^\w{1}[-\w]*$/i", $serviceName);
if (!$is_valid)
echo "Value '{$serviceName}' not allowed\n";

} while(!$is_valid);

}

if (file_exists("{$installDir}/vendor/simplesamlphp/simplesamlphp/log/simplesamlphp.log")) {
Expand Down

0 comments on commit caeb5ed

Please sign in to comment.