Skip to content

Add re-auth and re-configure flow to libreNMS - #180301

Open
mib1185 wants to merge 2 commits into
devfrom
librenms/add-reauth-and-reconfigure-flow
Open

Add re-auth and re-configure flow to libreNMS#180301
mib1185 wants to merge 2 commits into
devfrom
librenms/add-reauth-and-reconfigure-flow

Conversation

@mib1185

@mib1185 mib1185 commented Aug 26, 2026

Copy link
Copy Markdown
Member

Proposed change

SSIA

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI left a comment

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.

Pull request overview

Adds LibreNMS reauthentication and reconfiguration flows, including validation, translations, and tests.

Changes:

  • Adds API-key reauthentication and connection reconfiguration.
  • Adds flow translations and test coverage.
  • Promotes LibreNMS to Silver quality scale.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
homeassistant/components/librenms/config_flow.py Implements reauthentication and reconfiguration flows.
homeassistant/components/librenms/strings.json Adds flow translations.
homeassistant/components/librenms/manifest.json Promotes the integration to Silver.
homeassistant/components/librenms/quality_scale.yaml Marks both flows complete.
tests/components/librenms/test_config_flow.py Tests successful and failing flow paths.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +190 to +191
else:
try:

return self.async_show_form(
step_id="reauth_confirm",
data_schema=vol.Schema({vol.Required(CONF_API_KEY): str}),
entry = self._get_reconfigure_entry()
current_data = entry.data

url = f"{'https' if current_data[CONF_SSL] else 'http'}://{current_data[CONF_HOST]}:{current_data[CONF_PORT]}"
url = user_input[CONF_URL]
verify_ssl = user_input[CONF_VERIFY_SSL]
try:
(host, port, ssl) = _parse_url(user_input[CONF_URL])
Copilot AI review requested due to automatic review settings August 26, 2026 16:16

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (4)

homeassistant/components/librenms/config_flow.py:166

  • Render the API key with a password selector. Using str makes reauthentication show a normal text field, unlike the initial flow at lines 45–47, so the credential is visible while entered.
            data_schema=vol.Schema({vol.Required(CONF_API_KEY): str}),

homeassistant/components/librenms/config_flow.py:179

  • Build the suggested URL with URL.build. Concatenating an IPv6 host such as ::1 produces https://::1:443, so opening reconfigure for an existing IPv6 entry supplies an invalid default; the coordinator already uses URL.build to bracket these hosts correctly.
        url = f"{'https' if current_data[CONF_SSL] else 'http'}://{current_data[CONF_HOST]}:{current_data[CONF_PORT]}"

homeassistant/components/librenms/config_flow.py:191

  • Abort when another entry already uses the submitted host and port. The user flow enforces this pair as the integration's uniqueness key, but reconfigure currently skips the same check, allowing two entries to target one LibreNMS instance.
            else:
                try:

homeassistant/components/librenms/config_flow.py:187

  • Reject URL schemes other than HTTP and HTTPS. _parse_url maps every non-HTTPS scheme to ssl=False, so an input such as ftp://librenms:443 can pass parsing and be saved as an HTTP endpoint instead of returning invalid_url; the URL selector only controls the browser input type and does not validate the scheme server-side.
                (host, port, ssl) = _parse_url(user_input[CONF_URL])

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.

2 participants