Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(Inventory): Basic auth for Agent #17834

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Glpi/Agent/Communication/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ public function handleRequest($data): bool
}
}

/*if ($auth_required === 'basic_authentification') {

}*/

MyvTsv marked this conversation as resolved.
Show resolved Hide resolved
// Some network inventories may request may contains lots of information.
// e.g. a Huawei S5720-52X-LI-AC inventory file may weigh 20MB,
// and GLPI will consume about 500MB of memory to handle it,
Expand Down
45 changes: 42 additions & 3 deletions src/Glpi/Inventory/Conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,26 +384,63 @@ public function showConfigForm()
echo '</div>';
echo "</td>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
echo "<td>";
echo "<label for='auth'>" . __s('Authorization header') . "</label>";
echo "</td>";
echo "<td>";
Dropdown::showFromArray('auth_required', [
'none' => __('None'),
'client_credentials' => __('OAuth - Client credentials')
'client_credentials' => __('OAuth - Client credentials'),
'basic_authentification' => __('Basic Authentification'),
MyvTsv marked this conversation as resolved.
Show resolved Hide resolved
MyvTsv marked this conversation as resolved.
Show resolved Hide resolved
], [
'value' => $config['auth_required'] ?? 'none'
]);
echo "</td></tr>";
echo "<tr class='tab_bg_1' id='basic_auth_login_row'>";
echo "<td>";
echo "<label for='basic_auth_login'>" . __s('Login') . "</label>";
cedric-anne marked this conversation as resolved.
Show resolved Hide resolved
echo "</td>";
echo "<td>";
echo Html::input("basic_auth_login", [
"value" => $config["basic_auth_login"]
]);
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1' id='basic_auth_password_row'>";
echo "<td>";
echo "<label for='basic_auth_password'>" . __s('Password') . "</label>";
cedric-anne marked this conversation as resolved.
Show resolved Hide resolved
echo "</td>";
echo "<td>";
echo Html::input("basic_auth_password", [
"value" => $config["basic_auth_password"],
MyvTsv marked this conversation as resolved.
Show resolved Hide resolved
"type" => "password"
]);
echo "</td>";
echo "</tr>";
echo Html::scriptBlock("
function toggleDisplayLoginInputs(select) {
let displayedInputs = false;
const selectedValue = $(select).val();
if (selectedValue == 'basic_authentification') {
displayedInputs = true;
}
$('#basic_auth_login_row').toggle(displayedInputs);
$('#basic_auth_password_row').toggle(displayedInputs);
}

const selectAuthHeader = $(`select[name='auth_required']`);
selectAuthHeader.change(function() {
toggleDisplayLoginInputs(this);
});

toggleDisplayLoginInputs(selectAuthHeader);
");
echo "<tr>";
echo "<th colspan='4'>";
echo __('Import options');
echo "</th>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
echo "<td>";
echo "<label for='import_volume'>";
Expand Down Expand Up @@ -1226,6 +1263,8 @@ public static function getDefaults(): array
'stale_agents_status_condition' => exportArrayToDB(['all']),
'import_env' => 0,
'auth_required' => 'none',
'basic_auth_login' => '',
'basic_auth_password' => ''
];
}

Expand Down