'copy' button to copy passwords next to unlock #2167

Closed
opened 2025-12-29 17:22:57 +01:00 by adam · 4 comments
Owner

Originally created by @Ramshield on GitHub (Dec 2, 2018).

Environment

  • Python version: 3.5.3
  • NetBox version: 2.4.4

Hi,

I would love to see a copy button next to the 'unlock' button for passwords under secrets menu.
Is this something that is easily to implement?
Unfortunately I'm just a simple user and have no knowledge on how to do such thing myself.

Proposed Functionality

Add a simple 'copy' button next to the unlock button on the device page.
http://example.com/dcim/devices/1/ under 'Secrets'.

External Dependencies

Originally created by @Ramshield on GitHub (Dec 2, 2018). ### Environment * Python version: 3.5.3 * NetBox version: 2.4.4 Hi, I would love to see a copy button next to the 'unlock' button for passwords under secrets menu. Is this something that is easily to implement? Unfortunately I'm just a simple user and have no knowledge on how to do such thing myself. ### Proposed Functionality Add a simple 'copy' button next to the unlock button on the device page. http://example.com/dcim/devices/1/ under 'Secrets'. ### External Dependencies
adam added the status: acceptedtype: feature labels 2025-12-29 17:22:57 +01:00
adam closed this issue 2025-12-29 17:22:57 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 3, 2018):

I looked into this a while back but didn't find a consistently supported mechanism for implementing this. Maybe support for copy-to-clipboard has gotten better since then.

@jeremystretch commented on GitHub (Dec 3, 2018): I looked into this a while back but didn't find a consistently supported mechanism for implementing this. Maybe support for copy-to-clipboard has gotten better since then.
Author
Owner

@hSaria commented on GitHub (Feb 2, 2019):

Are you okay with having to unlock the secret first and then be presented with the copy button? If so, I can submit a PR for that.

Due to security restrictions imposed by browsers, attempts to modify the clipboard need to be associated with an event. As a consequence, I cannot make the AJAX request (unlock) and then copy the secret since the click event was already processed; the browser would block the request to modify the clipboard. From what I can see, you either:

  1. have to make the original AJAX request sync, which is a terrible idea (you just have JAX at that point), or
  2. separate the two unlock from the copy.

Let me know what you think. From my point of view, I think it's handy to be able to copy the password, but I'd rather have it so that I can do so without seeing the password, which wouldn't work using my current solution. A variant of this would be to make unlocking the secret not show it by default, until the user hits a show-me button, just like a normal password field.

@hSaria commented on GitHub (Feb 2, 2019): Are you okay with having to unlock the secret first and then be presented with the copy button? If so, I can submit a PR for that. Due to security restrictions imposed by browsers, attempts to modify the clipboard need to be associated with an event. As a consequence, I cannot make the AJAX request (unlock) and then copy the secret since the click event was already processed; the browser would block the request to modify the clipboard. From what I can see, you either: 1. have to make the original AJAX request sync, which is a terrible idea (you just have JAX at that point), or 2. separate the two unlock from the copy. Let me know what you think. From my point of view, I think it's handy to be able to copy the password, but I'd rather have it so that I can do so without seeing the password, which wouldn't work using my current solution. A variant of this would be to make unlocking the secret not show it by default, until the user hits a show-me button, just like a normal password field.
Author
Owner

@Ramshield commented on GitHub (Feb 2, 2019):

It's okay to have it unlocked first, I'd be okay with that, thanks for taking a look at it!

@Ramshield commented on GitHub (Feb 2, 2019): It's okay to have it unlocked first, I'd be okay with that, thanks for taking a look at it!
Author
Owner

@hSaria commented on GitHub (Feb 3, 2019):

copy-secret
All done @Ramshield. Hopefully you like it.

@hSaria commented on GitHub (Feb 3, 2019): ![copy-secret](https://user-images.githubusercontent.com/34197532/52176015-f6c90600-27a4-11e9-8542-c9127d7a8cf7.gif) All done @Ramshield. Hopefully you like it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2167