Skip to content

Update httpapi login and logout to support 4.2.1+#282

Open
mtarking wants to merge 4 commits into
developfrom
update_httpapi_auth
Open

Update httpapi login and logout to support 4.2.1+#282
mtarking wants to merge 4 commits into
developfrom
update_httpapi_auth

Conversation

@mtarking
Copy link
Copy Markdown
Collaborator

@mtarking mtarking commented May 17, 2026

Related Issue(s)

Proposed Changes

Updates the httpapi plugin (plugins/httpapi/nd.py) to auto-detect whether the Nexus Dashboard instance uses the new authentication endpoints (/api/v1/infra/login, /api/v1/infra/logout) introduced in ND 4.2.1+ or the legacy endpoints (/login, /logout).

  • Added _attempt_login() helper method that encapsulates a single login attempt and returns (token, status)
  • Updated login() with auto-detection logic: tries /api/v1/infra/login first, falls back to /login on failure
  • Caches the detected auth base path (self.auth_base_path) so subsequent re-authentication skips detection
  • Updated logout() to use the detected path (/api/v1/infra/logout or /logout)
  • Token parsing now reads jwttoken first, falling back to token

No configuration changes required — detection is transparent and existing inventories/playbooks work without modification. API key auth (ansible_httpapi_session_key) is unaffected since it skips login entirely.

Test Notes

  • Verified syntax compiles cleanly
  • Manual tested against ND < 4.2.1 (legacy /login) and ND >= 4.2.1 (/api/v1/infra/login)
  • API key auth path unchanged and unaffected

Cisco Nexus Dashboard Version

  • Developed against ND 4.2.1+
  • Backward compatible with ND 3.2.2m

Related ND API Resource Category

  • analyze
  • infa
  • manage
  • onemanage
  • other

Checklist

  • Latest commit is rebased from develop with merge conflicts resolved
  • New or updates to documentation has been made accordingly
  • Assigned the proper reviewers

@mtarking mtarking self-assigned this May 17, 2026
gmicol
gmicol previously approved these changes May 20, 2026
Copy link
Copy Markdown
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread plugins/httpapi/nd.py Outdated
Comment thread plugins/httpapi/nd.py Outdated
Comment thread plugins/httpapi/nd.py Outdated
Comment thread plugins/httpapi/nd.py Outdated
Comment thread plugins/httpapi/nd.py Outdated
Comment thread plugins/httpapi/nd.py Outdated
Comment thread plugins/httpapi/nd.py Outdated
@mtarking mtarking requested review from akinross and gmicol May 20, 2026 18:54
@mtarking mtarking marked this pull request as ready for review May 20, 2026 18:55
Copy link
Copy Markdown
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

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

LGTM

@mtarking mtarking added enhancement New feature or request 2.0.0 Release 2.0.0 nda-project Move this issue to the NDA project labels May 20, 2026
Comment thread plugins/httpapi/nd.py Outdated
Co-authored-by: Samita B <samitab@cisco.com>
@mtarking mtarking requested a review from samiib May 27, 2026 13:59
Copy link
Copy Markdown
Collaborator

@samiib samiib left a comment

Choose a reason for hiding this comment

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

LGTM

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

Labels

2.0.0 Release 2.0.0 enhancement New feature or request nda-project Move this issue to the NDA project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants