Skip to content

Commit 82db8a9

Browse files
committed
Update documentation
1 parent bb75bce commit 82db8a9

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

docs/configuration/required-parameters.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,31 @@ ALLOWED_HOSTS = ['*']
2323

2424
---
2525

26+
## API_TOKEN_PEPPERS
27+
28+
!!! info "This parameter was introduced in NetBox v4.5."
29+
30+
[Cryptographic peppers](https://en.wikipedia.org/wiki/Pepper_(cryptography)) are employed to generate hashes of sensitive values on the server. This parameter defines the peppers used to hash v2 API tokens in NetBox. You must define at least one pepper before creating a v2 API token. See the [API documentation](../integrations/rest-api.md#authentication) for further information about how peppers are used.
31+
32+
```python
33+
API_TOKEN_PEPPERS = {
34+
# DO NOT USE THIS EXAMPLE PEPPER IN PRODUCTION
35+
1: 'kp7ht*76fiQAhUi5dHfASLlYUE_S^gI^(7J^K5M!LfoH@vl&b_',
36+
}
37+
```
38+
39+
!!! warning "Peppers are sensitive"
40+
Treat pepper values as extremely sensitive. Consider populating peppers from environment variables at initialization time rather than defining them in the configuration file, if feasible.
41+
42+
Peppers must be at least 50 characters in length and should comprise a random string with a diverse character set. Consider using the Python script at `$INSTALL_ROOT/netbox/generate_secret_key.py` to generate a pepper value.
43+
44+
It is recommended to start with a pepper ID of `1`. Additional peppers can be introduced later as needed to begin rotating token hashes.
45+
46+
!!! tip
47+
Although NetBox will run without `API_TOKEN_PEPPERS` defined, the use of v2 API tokens will be unavailable.
48+
49+
---
50+
2651
## DATABASE
2752

2853
!!! warning "Legacy Configuration Parameter"

docs/installation/3-netbox.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,23 @@ If you are not yet sure what the domain name and/or IP address of the NetBox ins
120120
ALLOWED_HOSTS = ['*']
121121
```
122122

123+
### API_TOKEN_PEPPERS
124+
125+
Define at least one random cryptographic pepper, identified by a numeric ID starting at 1. This will be used to generate SHA256 checksums for API tokens.
126+
127+
```python
128+
API_TOKEN_PEPPERS = {
129+
# DO NOT USE THIS EXAMPLE PEPPER IN PRODUCTION
130+
1: 'kp7ht*76fiQAhUi5dHfASLlYUE_S^gI^(7J^K5M!LfoH@vl&b_',
131+
}
132+
```
133+
134+
!!! tip
135+
As with [`SECRET_KEY`](#secret_key) below, you can use the `generate_secret_key.py` script to generate a random pepper:
136+
```no-highlight
137+
python3 ../generate_secret_key.py
138+
```
139+
123140
### DATABASES
124141

125142
This parameter holds the PostgreSQL database configuration details. The default database must be defined; additional databases may be defined as needed e.g. by plugins.

docs/integrations/rest-api.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -653,19 +653,17 @@ The NetBox REST API primarily employs token-based authentication. For convenienc
653653

654654
### Tokens
655655

656-
A token is a unique identifier mapped to a NetBox user account. Each user may have one or more tokens which he or she can use for authentication when making REST API requests. To create a token, navigate to the API tokens page under your user profile.
656+
A token is a secret, unique identifier mapped to a NetBox user account. Each user may have one or more tokens which he or she can use for authentication when making REST API requests. To create a token, navigate to the API tokens page under your user profile. When creating a token, NetBox will automatically populate a randomly-generated token value.
657657

658658
By default, all users can create and manage their own REST API tokens under the user control panel in the UI or via the REST API. This ability can be disabled by overriding the [`DEFAULT_PERMISSIONS`](../configuration/security.md#default_permissions) configuration parameter.
659659

660-
!!! info "Token Versions"
661-
Beginning with NetBox v4.5, two types of API token are supported, denoted as v1 and v2. Users are strongly encouraged to create only v2 tokens, as these provide much stronger security than v1 tokens. Support for v1 tokens will be removed in a future NetBox release.
660+
Additionally, a token can be set to expire at a specific time. This can be useful if an external client needs to be granted temporary access to NetBox.
662661

663-
When creating a token, you'll typically leave the key field blank so that a random key will be automatically generated. However, NetBox allows you to specify a key in case you need to restore a previously deleted token to operation.
662+
#### v1 and v2 Tokens
664663

665-
Additionally, a token can be set to expire at a specific time. This can be useful if an external client needs to be granted temporary access to NetBox.
664+
Beginning with NetBox v4.5, two versions of API token are supported, denoted as v1 and v2. Users are strongly encouraged to create only v2 tokens and to discontinue the use of v1 tokens. Support for v1 tokens will be removed in a future NetBox release.
666665

667-
!!! info "Restricting Token Retrieval"
668-
The ability to retrieve the key value of a previously-created API token can be restricted by disabling the [`ALLOW_TOKEN_RETRIEVAL`](../configuration/security.md#allow_token_retrieval) configuration parameter.
666+
v2 API tokens offer much stronger security. The token plaintext given at creation time is hashed together with a configured [cryptographic pepper](../configuration/required-parameters.md#api_token_peppers) to generate a unique checksum. This checksum is irreversible; the token plaintext is never stored on the server and thus cannot be retrieved.
669667

670668
#### Restricting Write Operations
671669

0 commit comments

Comments
 (0)