some changes
This commit is contained in:
@@ -3,7 +3,7 @@ session_start();
|
|||||||
include("../lib/db.php");
|
include("../lib/db.php");
|
||||||
include("../config/config.php");
|
include("../config/config.php");
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && AUTH_TYPE === 'local') {
|
||||||
$username = $_POST['username'];
|
$username = $_POST['username'];
|
||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
$stmt = $conn->prepare("SELECT * FROM admin WHERE username = ?");
|
$stmt = $conn->prepare("SELECT * FROM admin WHERE username = ?");
|
||||||
@@ -20,8 +20,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
}
|
}
|
||||||
$error = "Credenziali non valide";
|
$error = "Credenziali non valide";
|
||||||
}
|
}
|
||||||
?>
|
if (AUTH_TYPE === 'local') {
|
||||||
<!DOCTYPE html>
|
echo ```<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Login Admin</title>
|
<title>Login Admin</title>
|
||||||
@@ -49,4 +49,25 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
</div>
|
</div>
|
||||||
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under <a href="https://git.vichingo455.freeddns.org/emmev-code/orario/src/branch/stable/LICENSE.txt" target="_blank">GNU AGPL 3.0 License</a>.</p>
|
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under <a href="https://git.vichingo455.freeddns.org/emmev-code/orario/src/branch/stable/LICENSE.txt" target="_blank">GNU AGPL 3.0 License</a>.</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>```;
|
||||||
|
}
|
||||||
|
else if (AUTH_TYPE === 'keycloak') {
|
||||||
|
require 'vendor/autoload.php';
|
||||||
|
use Jumbojett\OpenIDConnectClient;
|
||||||
|
session_start();
|
||||||
|
// Configura il client Keycloak
|
||||||
|
$oidc = new OpenIDConnectClient(
|
||||||
|
'https://' + KEYCLOAK_DOMAIN + '/realms/' + KEYCLOAK_REALM + '/',
|
||||||
|
KEYCLOAK_CLIENT_ID,
|
||||||
|
KEYCLOAK_CLIENT_SECRET
|
||||||
|
);
|
||||||
|
// Redirect post-login
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
require 'vendor/autoload.php';
|
|
||||||
use Jumbojett\OpenIDConnectClient;
|
|
||||||
session_start();
|
|
||||||
// Configura il client Keycloak
|
|
||||||
$oidc = new OpenIDConnectClient(
|
|
||||||
'https://<KEYCLOAK_URL>/realms/<REALM>/',
|
|
||||||
'<CLIENT_ID>',
|
|
||||||
'<CLIENT_SECRET>'
|
|
||||||
);
|
|
||||||
// Redirect post-login
|
|
||||||
$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;
|
|
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
include("../config/config.php");
|
||||||
session_start();
|
session_start();
|
||||||
session_destroy();
|
session_destroy();
|
||||||
header("Location: /index.php");
|
if (AUTH_TYPE === 'local')
|
||||||
|
header("Location: /index.php");
|
||||||
|
else if (AUTH_TYPE === 'keycloak')
|
||||||
|
header('Location: https://' + KEYCLOAK_DOMAIN + '/realms/' + KEYCLOAK_REALM + '/protocol/openid-connect/logout?post_logout_redirect_uri=https://' + APP_DOMAIN + '&client_id=' + KEYCLOAK_CLIENT_ID);
|
||||||
?>
|
?>
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
session_destroy();
|
|
||||||
header('Location: https://<KEYCLOAK_URL>/realms/<REALM>/protocol/openid-connect/logout?post_logout_redirect_uri=https://<APP_DOMAIN>&client_id=<CLIENT_ID>');
|
|
||||||
exit;
|
|
@@ -12,5 +12,6 @@ define('AUTH_TYPE','local'); // Può essere keycloak o local (integrata)
|
|||||||
define('KEYCLOAK_DOMAIN','');
|
define('KEYCLOAK_DOMAIN','');
|
||||||
define('KEYCLOAK_REALM','');
|
define('KEYCLOAK_REALM','');
|
||||||
define('KEYCLOAK_CLIENT_ID','');
|
define('KEYCLOAK_CLIENT_ID','');
|
||||||
define('KEYCLOAK_CLIENT_SECRET','')
|
define('KEYCLOAK_CLIENT_SECRET','');
|
||||||
|
define('APP_DOMAIN','');
|
||||||
?>
|
?>
|
@@ -38,7 +38,7 @@ if ($res->num_rows === 0) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="logo">Orario Scuola 2025/26</div>
|
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||||
<div class="links">
|
<div class="links">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -35,7 +35,7 @@ if ($res->num_rows === 0) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="logo">Orario Scuola 2025/26</div>
|
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||||
<div class="links">
|
<div class="links">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -36,7 +36,7 @@ if ($res->num_rows === 0) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="logo">Orario Scuola 2025/26</div>
|
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||||
<div class="links">
|
<div class="links">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user