Skip to content

Commit

Permalink
Temporary hack to avoid name collision without renaming the secrets app
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Feb 18, 2020
1 parent 01b9d1a commit f1b0421
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions netbox/secrets/__init__.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f1b0421

Please sign in to comment.