Skip to content

feat(nautobotop): determine the username from the supplied token#1905

Open
cardoe wants to merge 1 commit intomainfrom
nautobotop-username
Open

feat(nautobotop): determine the username from the supplied token#1905
cardoe wants to merge 1 commit intomainfrom
nautobotop-username

Conversation

@cardoe
Copy link
Copy Markdown
Contributor

@cardoe cardoe commented Apr 1, 2026

Avoid an issue where the username supplied is different than the token
the user is for by always looking up the user that the token belongs to
for the queries.

Purposefully did not run:

  • make manifests
  • make copy-crds-to-helm

So that we have a transition period in removing the username.

@cardoe cardoe requested a review from a team April 1, 2026 16:24
@cardoe cardoe force-pushed the nautobotop-username branch from 9b87f11 to c6cbbde Compare April 1, 2026 21:15
Avoid an issue where the username supplied is different than the token
the user is for by always looking up the user that the token belongs to
for the queries.

Purposefully did not run:
- make manifests
- make copy-crds-to-helm

So that we have a transition period in removing the username.
@cardoe cardoe force-pushed the nautobotop-username branch from c6cbbde to 5e5fc85 Compare April 1, 2026 22:24
@abhimanyu003
Copy link
Copy Markdown
Contributor

abhimanyu003 commented Apr 2, 2026

I like the change but looks like it not yet ready to merge.

Few things I noticed that response from Nautobot api is like this, it only exposing displayname and not the username

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": "11a6f69f-89df-47b5-a1a9-cda64bd7d324",
      "object_type": "users.token",
      "display": "yTCXFP (admin)",
      "url": "http://192.168.194.196/api/users/tokens/11a6f69f-89df-47b5-a1a9-cda64bd7d324/",
      "natural_slug": "11a6f69f-89df-47b5-a1a9-cda64bd7d324_11a6",
      "key": "ck7bsgfapcW2UNyzfaNf7qD07SRAcPog38yTCXFP",
      "expires": null,
      "write_enabled": true,
      "description": "",
      "created": "2026-04-02T09:48:23.056821Z"
    }
  ]
}

Other concerns.

  • If there are multiple CRs with different tokens, they'll all share the same cached username from whichever CR reconciled first.

  • If the token is rotated, the cached username becomes stale. There's no invalidation path since resolvedUsername is set once and never cleared. Untill we restart the Nautobot OP Controller POD.

Sure I want to add this change, but there can some slightly better way.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants