Skip to content

feat(gorgone): use /administation/tokens endpoint to validate POLLER_TOKEN on Central#3465

Open
sdepassio wants to merge 8 commits into
developfrom
MON-198541-central-gorgone-use-administation-tokens-endpoint-to-validate-poller-token
Open

feat(gorgone): use /administation/tokens endpoint to validate POLLER_TOKEN on Central#3465
sdepassio wants to merge 8 commits into
developfrom
MON-198541-central-gorgone-use-administation-tokens-endpoint-to-validate-poller-token

Conversation

@sdepassio

@sdepassio sdepassio commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

Use /administration/tokens/ Centreon API endpoint to validate pollers token.
Token from the conf file is used if the token isn't found with the API, so the "old way" is still working.
The token is invalid if it's revoked or expired, and we check that they're all still valid every 5 seconds.

Fixes MON-198541

Type of change

  • Patch fixing an issue (non-breaking change)
  • New functionality (non-breaking change)
  • Breaking change (patch or feature) that might cause side effects breaking part of the Software
  • Updating documentation (missing information, typo...)

Target serie

  • 23.10.x
  • 24.04.x
  • 24.10.x
  • 25.10.x
  • master

How this pull request can be tested ?

See automated test:

  • create a poller token in Centreon administration,
  • add a pullwss poller,
  • set an environment variable "GORGONE_TOKEN" with the value "tokenName:tokenValue" on the poller and remove the token in the gorgone configuration => the poller should be able to communicate with the central,
  • revoke the token, or wait until it is expired => the poller should be deconnected and cannot communicate with the central.

Checklist

  • I have followed the coding style guidelines provided by Centreon
  • I have commented my code, especially new classes, functions or any legacy code modified. (docblock)
  • I have commented my code, especially hard-to-understand areas of the PR.
  • I have made corresponding changes to the documentation.
  • I have rebased my development branch on the base branch (master, maintenance).

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • coderabbit

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 91bcf248-2bb4-4a86-bb6d-81a0e793d835

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MON-198541-central-gorgone-use-administation-tokens-endpoint-to-validate-poller-token

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sdepassio sdepassio marked this pull request as ready for review June 18, 2026 07:31
@sdepassio sdepassio requested review from a team as code owners June 18, 2026 07:31
@sdepassio sdepassio requested review from Evan-Adam, jean-christophe81 and scresto31 and removed request for a team and jean-christophe81 June 18, 2026 07:31
Comment thread gorgone/gorgone/modules/core/proxy/httpserver.pm Outdated
Comment thread gorgone/gorgone/modules/core/proxy/httpserver.pm Outdated
Comment thread gorgone/gorgone/class/tpapi/centreonv2.pm Outdated
);
}
} else {
$self->{logger}->writeLogDebug('[proxy-httpserver] cannot get token ' . $token_name . ' - ' . $self->{tpapi_centreonv2}->error());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the token does not exist you should disconnect the poller. I think you can invert your l212 condition to if (status != 0 or !defined($results->{token} or $results->{is_revoked} or str2time($results->{expiration_date}) < time()))

${log_central_query} Create List [proxy-httpserver] invalid token
# The poller is connected
Check Poller Is Connected port=8086 expected_nb=2
${logs_central} Ctn Find In Log With Timeout log=/var/log/centreon-gorgone/pullwss_gorgone_central_simple/gorgoned.log content=${log_central_query} date=${start_date}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default this search the log for 20 second, is it really what you want ?
I think if you start the search before the start (as l127 show) then you can either not wait 20 second or wait and call it only once or check each time you see the "recurring token revocation check" log

Ctn Check No Error In Logs ${mode}_gorgone_poller_2_simple
# we need to find the message that explains the connection refusal
${log_central_query} Create List ${message}
${logs_central} Ctn Find In Log With Timeout log=/var/log/centreon-gorgone/${mode}_gorgone_central_simple/gorgoned.log content=${log_central_query} date=${start_date} timeout=70

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not checking the poller get a disconnect instead of the central ? the central can create a log saying "disconnecting" without actually making any action, checking the poller allows to be sure the action was realized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants