diff --git a/docker/php/config.php b/docker/php/config.php index 059d377..47ce5ae 100644 --- a/docker/php/config.php +++ b/docker/php/config.php @@ -43,5 +43,8 @@ if (AUTH_TYPE === 'keycloak') { if (!defined('KEYCLOAK_CLIENT_SECRET')) { define('KEYCLOAK_CLIENT_SECRET',''); // Client Secret per Keycloak (ad esempio abcdefghijklm) } + if (!defined('KEYCLOAK_ALLOWED_USERS')) { + define('KEYCLOAK_ALLOWED_USERS',[]); // Contiene i nomi utente degli utenti autorizzati ad accedere all'amministrazione + } } ?> \ No newline at end of file diff --git a/htdocs/admin/login.php b/htdocs/admin/login.php index 551d8ea..d4beef3 100644 --- a/htdocs/admin/login.php +++ b/htdocs/admin/login.php @@ -72,10 +72,41 @@ else if (AUTH_TYPE === 'keycloak') { $oidc->setRedirectURL('https://' . APP_DOMAIN . '/admin/login.php'); $oidc->authenticate(); $userinfo = $oidc->getVerifiedClaims(); - $_SESSION['admin'] = $userinfo->preferred_username; - $_SESSION['auth_type'] = 'keycloak'; - header("Location: index.php"); - exit; + if (in_array($userinfo->preferred_username, KEYCLOAK_ALLOWED_USERS, true) || empty(KEYCLOAK_ALLOWED_USERS)) { + $_SESSION['admin'] = $userinfo->preferred_username; + $_SESSION['auth_type'] = 'keycloak'; + header("Location: index.php"); + exit; + } else { + http_response_code(403); + echo << + +
+Copyright (C) 2025 EmmeV. - Released under GNU AGPL 3.0 License.
+ + +HTML; + exit; + } } catch (Exception $e) { http_response_code(500); echo << \ No newline at end of file