-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the applicationIntroduction of new functionality to the application
Description
NetBox version
v3.3.7
Feature type
Change to existing functionality
Proposed functionality
We need to be able to access cookies from Netbox Scripts, so we can pass the Secret Store Plugin Session Key (that is stored in a cookie). Right now, we modified the utils.py copy_safe_request() function to also expose those.
--- netbox/netbox/utilities/utils.py 2022-11-04 11:52:55.773780916 +0100
+++ netbox/netbox/utilities/utils.py 2022-11-02 08:50:06.691425078 +0100
@@ -342,6 +342,7 @@
}
return NetBoxFakeRequest({
'META': meta,
+ 'COOKIES': request.COOKIES,
'POST': request.POST,
'GET': request.GET,
'FILES': request.FILES,Use case
We need to store a secret from a "Create Device" Script. If the proposed patch is accepted, the following code works:
session_key = self.request.COOKIES.get('session_key')
sk = SessionKey.objects.get(userkey__user=self.request.user)
master_key = sk.get_master_key(base64.b64decode(session_key))
It appears, this feature request was previously submitted as #7672, but got auto-closed due to inactivity.
Database changes
none.
External dependencies
none.
Metadata
Metadata
Assignees
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the applicationIntroduction of new functionality to the application