Skip to content

Commit

Permalink
Update config.inc.php
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpejcic authored Sep 13, 2024
1 parent 1509e4f commit 4c5912c
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions docker/ubuntu_apache_mariadb/phpmyadmin/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,19 @@ function check_file_access($path)
}

if (!empty($dbname)) {
// Check for HTTPS using the X-Forwarded-Proto header
$isHttps = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ||
(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https');

if ($isHttps) {
// Use cookie authentication for HTTPS connections
error_log("Using cookie authentication for HTTPS");
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = ''; // Username will be entered in the login form
$cfg['Servers'][$i]['password'] = '';
} else {
// Use Single Sign-On (SSO) for the random ip
error_log("Using Single Sign-On (SSO) for IP: $allowedIp");
$serverPort = $_SERVER['SERVER_PORT'];
// AUTOLOGIN FROM OPENPANEL UI
if ($serverPort != 80 && $serverPort != 443) {
error_log("Using Single Sign-On (SSO) for connections from OpenPanel: $clientIp");
$cfg['Servers'][$i]['auth_type'] = 'signon';
$cfg['Servers'][$i]['SignonSession'] = 'OPENPANEL_PHPMYADMIN';
$cfg['Servers'][$i]['SignonURL'] = 'pma.php';
// LOGIN FORM ON DOMAIN/phpmyadmin
} else {
error_log("Using cookie authentication for connection via domain name");
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';
}

/* Server parameters */
Expand Down

0 comments on commit 4c5912c

Please sign in to comment.