1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Introduced a script to generate SECRET_KEY; removed example SECRET_KEY

This commit is contained in:
Jeremy Stretch
2016-06-21 14:07:47 -04:00
parent 67d5d008b9
commit df55ec0114
3 changed files with 23 additions and 19 deletions

View File

@ -15,7 +15,7 @@ This is a list of valid fully-qualified domain names (FQDNs) for the NetBox serv
Example: 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) * 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) * 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 #### 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. 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: `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.
```
import os
import random
charset = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
random.seed = (os.urandom(2048))
print ''.join(random.choice(charset) for c in range(50))
```
# Optional Settings # Optional Settings

View File

@ -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. 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: You may use the script located at `netbox/generate_secret_key.py` to generate a suitable key.
```
SECRET_KEY = '^6-ub1!t@ty5tomzkp6-ag0_y$kckdk2lmbx2$ya2r+ikk5&#d'
```
DO NOT COPY AND PASTE THE KEY FROM THE EXAMPLE.
## Run Migrations ## Run Migrations

8
netbox/generate_secret_key.py Executable file
View File

@ -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))