Skip to content

Commit

Permalink
Fix the register agent selected cluster/manager config endpoint (#6213)
Browse files Browse the repository at this point in the history
* Fix the cluster conditional to choose the endpoints

* Add changelog
  • Loading branch information
asteriscos authored Dec 13, 2023
1 parent f871ede commit 192c107
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ All notable changes to the Wazuh app project will be documented in this file.

### Added

- Added contextual information in the register agent commands [#6208](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6208)
- Support for Wazuh 4.7.2
- Added contextual information in the register agent commands [#6208](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6208)
- Added host name and board serial information to Agents > Inventory data [#6191](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6191)

### Fixed

- Fixed Agents preview page load when there are no registered agents [#6185](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6185)
- Fixed the endpoint to get Wazuh server auth configuration [#6206](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6206)
- Fixed the endpoint to get Wazuh server auth configuration [#6206](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6206) [#6213](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6213)

## Wazuh v4.7.1 - OpenSearch Dashboards 2.8.0 - Revision 01

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ export const clusterStatusResponse = async (): Promise<boolean> => {
/**
* Get the remote configuration from api
*/
async function getRemoteConfiguration(nodeName: string): Promise<RemoteConfig> {
async function getRemoteConfiguration(
nodeName: string,
clusterStatus: boolean,
): Promise<RemoteConfig> {
let config: RemoteConfig = {
name: nodeName,
isUdp: false,
haveSecureConnection: false,
};

try {
const clusterStatus = await clusterStatusResponse();
let result;
if (clusterStatus) {
result = await WzRequest.apiReq(
Expand Down Expand Up @@ -97,8 +99,8 @@ async function getRemoteConfiguration(nodeName: string): Promise<RemoteConfig> {
* @param node
* @returns
*/
async function getAuthConfiguration(node?: string) {
const authConfigUrl = node
async function getAuthConfiguration(node: string, clusterStatus: boolean) {
const authConfigUrl = clusterStatus
? `/cluster/${node}/configuration/auth/auth`
: '/manager/configuration/auth/auth';
const result = await WzRequest.apiReq('GET', authConfigUrl, {});
Expand Down Expand Up @@ -131,7 +133,11 @@ async function getConnectionConfig(
const nodeIp = nodeSelected?.value;
if (!defaultServerAddress) {
if (nodeSelected.nodetype !== 'custom') {
const remoteConfig = await getRemoteConfiguration(nodeName);
const clusterStatus = await clusterStatusResponse();
const remoteConfig = await getRemoteConfiguration(
nodeName,
clusterStatus,
);
return {
serverAddress: nodeIp,
udpProtocol: remoteConfig.isUdp,
Expand Down Expand Up @@ -232,8 +238,12 @@ export const getMasterNode = (nodeIps: any[]): any[] => {
export const getMasterConfiguration = async () => {
const nodes = await fetchClusterNodesOptions();
const masterNode = getMasterNode(nodes);
const remote = await getRemoteConfiguration(masterNode[0].label);
const auth = await getAuthConfiguration(masterNode[0].label);
const clusterStatus = await clusterStatusResponse();
const remote = await getRemoteConfiguration(
masterNode[0].label,
clusterStatus,
);
const auth = await getAuthConfiguration(masterNode[0].label, clusterStatus);
return {
remote,
auth,
Expand Down

0 comments on commit 192c107

Please sign in to comment.