From df55ec0114416ece684b872d11c08ac80d67dba7 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 21 Jun 2016 14:07:47 -0400 Subject: [PATCH] Introduced a script to generate SECRET_KEY; removed example SECRET_KEY --- docs/configuration.md | 26 ++++++++++++++------------ docs/getting-started.md | 8 +------- netbox/generate_secret_key.py | 8 ++++++++ 3 files changed, 23 insertions(+), 19 deletions(-) create mode 100755 netbox/generate_secret_key.py diff --git a/docs/configuration.md b/docs/configuration.md index 09b0be351..1a05c2250 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -15,7 +15,7 @@ This is a list of valid fully-qualified domain names (FQDNs) for the NetBox serv Example: ``` -ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local'] +ALLOWED_HOSTS = ['netbox.example.com', '192.0.2.123'] ``` --- @@ -30,6 +30,18 @@ NetBox requires access to a PostgreSQL database service to store data. This serv * HOST - Name or IP address of the database server (use `localhost` if running locally) * PORT - TCP port of the PostgreSQL service; leave blank for default port (5432) +Example: + +``` +DATABASE = { + 'NAME': 'netbox', # Database name + 'USER': 'netbox', # PostgreSQL username + 'PASSWORD': 'J5brHrAXFLQSif0K', # PostgreSQL password + 'HOST': 'localhost', # Database server + 'PORT': '', # Database port (leave blank for default) +} +``` + --- #### SECRET_KEY @@ -38,17 +50,7 @@ This is a secret cryptographic key is used to improve the security of cookies an Please note that this key is **not** used for hashing user passwords or for the encrypted storage of secret data in NetBox. -`SECRET_KEY` should be at least 50 characters in length and contain a random mix of letters, digits, and symbols. The following Python code can be used to generate a key: - - -``` -import os -import random - -charset = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' -random.seed = (os.urandom(2048)) -print ''.join(random.choice(charset) for c in range(50)) -``` +`SECRET_KEY` should be at least 50 characters in length and contain a random mix of letters, digits, and symbols. The script located at `netbox/generate_secret_key.py` may be used to generate a suitable key. # Optional Settings diff --git a/docs/getting-started.md b/docs/getting-started.md index f633ee3bd..640310af8 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -135,13 +135,7 @@ DATABASE = { Generate a random secret key of at least 50 alphanumeric characters. This key must be unique to this installation and must not be shared outside the local system. -Example: - -``` -SECRET_KEY = '^6-ub1!t@ty5tomzkp6-ag0_y$kckdk2lmbx2$ya2r+ikk5&#d' -``` - -DO NOT COPY AND PASTE THE KEY FROM THE EXAMPLE. +You may use the script located at `netbox/generate_secret_key.py` to generate a suitable key. ## Run Migrations diff --git a/netbox/generate_secret_key.py b/netbox/generate_secret_key.py new file mode 100755 index 000000000..d935910f6 --- /dev/null +++ b/netbox/generate_secret_key.py @@ -0,0 +1,8 @@ +#!/usr/bin/python +# This script will generate a random 50-character string suitable for use as a SECRET_KEY. +import os +import random + +charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*(-_=+)' +random.seed = (os.urandom(2048)) +print ''.join(random.choice(charset) for c in range(50))