Skip to content

Commit

Permalink
Merge pull request #1555 from OCSInventory-NG/dit-aix-contribution
Browse files Browse the repository at this point in the history
SSO_ONLY - Dit aix contribution
  • Loading branch information
Lea9250 authored Sep 4, 2023
2 parents 5b9c469 + 6e3d5c6 commit 7d314f5
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 10 deletions.
14 changes: 13 additions & 1 deletion backend/AUTH/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
} elseif ($affich_method == 'SSO' && isset($_SERVER['HTTP_AUTH_USER']) && !empty($_SERVER['HTTP_AUTH_USER'])) {
$login = $_SERVER['HTTP_AUTH_USER'];
$mdp = 'NO_PASSWD';
} elseif ($affich_method == 'SSO_ONLY' && isset($_SERVER['REMOTE_USER']) && !empty($_SERVER['REMOTE_USER'])) {
$login = $_SERVER['REMOTE_USER'];
$mdp = 'NO_PASSWD';
} elseif ($affich_method == 'SSO_ONLY' && isset($_SERVER['HTTP_AUTH_USER']) && !empty($_SERVER['HTTP_AUTH_USER'])) {
$login = $_SERVER['HTTP_AUTH_USER'];
$mdp = 'NO_PASSWD';
} elseif ($affich_method != 'HTML' && isset($_SERVER['PHP_AUTH_USER'])) {
$login = $_SERVER['PHP_AUTH_USER'];
$mdp = $_SERVER['PHP_AUTH_PW'];
Expand Down Expand Up @@ -230,7 +236,13 @@
} else if ($list_methode[0] == 'cas.php') {
// redirect to CAS login page
require_once('methode/' . $list_methode[0]);
} else {
} else if ($affich_method == "SSO_ONLY") {
// auth failed in SSO_ONLY mode, we display an error message
require_once (HEADER_HTML);
msg_error($l->g(180));
require_once(FOOTER_HTML);
die();
}else {
header('WWW-Authenticate: Basic realm="OcsinventoryNG"');
header('HTTP/1.0 401 Unauthorized');
die();
Expand Down
48 changes: 48 additions & 0 deletions backend/AUTH/methode/sso_only.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/*
* Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
* See the Contributors file for more details about them.
*
* This file is part of OCSInventory-NG/OCSInventory-ocsreports.
*
* OCSInventory-NG/OCSInventory-ocsreports is free software: you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the License,
* or (at your option) any later version.
*
* OCSInventory-NG/OCSInventory-ocsreports is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OCSInventory-NG/OCSInventory-ocsreports. if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
connexion_local_read();



$reqOp = "SELECT ID, USER_GROUP FROM operators WHERE ID='%s'";
$arg_reqOp = array($login);

$resOp = mysql2_query_secure($reqOp, $_SESSION['OCS']["readServer"], $arg_reqOp);
$rowOp = mysqli_fetch_object($resOp);

if (isset($rowOp->ID))
{
$login_successful = "OK";
$user_group = $rowOp->USER_GROUP;
$type_log = 'CONNEXION';
}
else
{
$login_successful = $l->g(180);
$type_log = 'BAD CONNEXION';
}


$value_log = 'USER:' . $login;
$cnx_origine = "SSO_ONLY";
?>
18 changes: 12 additions & 6 deletions backend/require/auth.manager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

<?php

/*
* Copyright 2005-2020 OCSInventory-NG/OCSInventory-ocsreports contributors.
* See the Contributors file for more details about them.
Expand All @@ -20,16 +20,18 @@
* along with OCSInventory-NG/OCSInventory-ocsreports. if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
*/
function get_affiche_methode(){
if(AUTH_TYPE == 4){
return "SSO";
} else if (AUTH_TYPE == 6) {
return "CAS";
} else if (AUTH_TYPE == 7) {
return "SSO_ONLY";
}else{
return "HTML";
}
}
}
function get_list_methode($identity = false){
switch (AUTH_TYPE) {
case 1:
Expand Down Expand Up @@ -68,9 +70,13 @@ function get_list_methode($identity = false){
);
break;

case 7:
return array(0=>($identity)?"local.php":"sso_only.php");
break;

default:
return array(
0 => "local.php"
);
}
}
}
}
3 changes: 1 addition & 2 deletions require/html_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@
}
echo "</li>";
}

if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['HTTP_AUTH_USER']) && (isset($_SESSION['OCS']['cnx_origine']) && $_SESSION['OCS']['cnx_origine'] != 'CAS')) {
if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['HTTP_AUTH_USER']) && (isset($_SESSION['OCS']['cnx_origine']) && ($_SESSION['OCS']['cnx_origine'] != 'CAS' && $_SESSION['OCS']['cnx_origine'] != 'SSO_ONLY'))) {
echo "<li><a onclick='return pag(\"ON\",\"LOGOUT\",\"log_out\")'>" . $l->g(251) . "</a></li>";
}
echo open_form('log_out', 'index.php');
Expand Down
2 changes: 1 addition & 1 deletion var.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
/**
* OCS' MySQL database version
*/

define('GUI_VER', '7075');

/**
Expand Down Expand Up @@ -149,6 +148,7 @@
* - 4 : LDAP with SSO
* - 5 : Always OK, won't ask for user and password
* - 6 : CAS authentication
* - 7 : SSO Only (using $_SERVER['REMOTE_USER'] / $_SERVER['HTTP_AUTH_USER'])
*
* If LDAP / SSO Basic auth is configured, please configure the LDAP Authentication
*/
Expand Down

0 comments on commit 7d314f5

Please sign in to comment.