From f1b042180536092fa99d67f55fe5d5ab280d0f69 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 18 Feb 2020 18:00:00 -0500 Subject: [PATCH] Temporary hack to avoid name collision without renaming the secrets app --- netbox/secrets/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/netbox/secrets/__init__.py b/netbox/secrets/__init__.py index e69de29bb..3c1c4eed2 100644 --- a/netbox/secrets/__init__.py +++ b/netbox/secrets/__init__.py @@ -0,0 +1,11 @@ +# TODO: Rename the secrets app, probably +# Python 3.6 introduced a standard library named "secrets," which obviously conflicts with this Django app. To avoid +# renaming the app, we hotwire the components of the standard library that Django calls. (I don't like this any more +# than you do, but it works for now.) The only references to the secrets modules are in django/utils/crypto.py. +# +# First, we copy secrets.compare_digest, which comes from the hmac module: +from hmac import compare_digest + +# Then, we instantiate SystemRandom and map its choice() function: +from random import SystemRandom +choice = SystemRandom().choice