Skip to content

Commit 0be96d4

Browse files
committed
Support new API_TOKEN format
Allows configuration the new API_TOKEN_PEPPERS setting from an ENV variable or secret file. Feature request: netbox-community/netbox#20210 Pull request: netbox-community/netbox#20477
1 parent f07c9d5 commit 0be96d4

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

.github/workflows/push.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ jobs:
3636
SUPPRESS_POSSUM: true
3737
LINTER_RULES_PATH: /
3838
VALIDATE_ALL_CODEBASE: false
39+
VALIDATE_BIOME_FORMAT: false
3940
VALIDATE_CHECKOV: false
4041
VALIDATE_DOCKERFILE: false
42+
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
4143
VALIDATE_GITLEAKS: false
4244
VALIDATE_JSCPD: false
4345
VALIDATE_TRIVY: false
44-
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
4546
FILTER_REGEX_EXCLUDE: (.*/)?(LICENSE|configuration/.*)
4647
EDITORCONFIG_FILE_NAME: .editorconfig-checker.json
4748
DOCKERFILE_HADOLINT_FILE_NAME: .hadolint.yaml

configuration/configuration.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ def _environ_get_and_map(variable_name: str, default: str | None = None, map_fn:
116116
# https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-SECRET_KEY
117117
SECRET_KEY = _read_secret('secret_key', environ.get('SECRET_KEY', ''))
118118

119+
API_TOKEN_PEPPERS = {}
120+
if api_token_pepper := _read_secret('api_token_pepper_1', environ.get('API_TOKEN_PEPPER_1', '')):
121+
API_TOKEN_PEPPERS.update({1: api_token_pepper})
122+
123+
119124

120125
#########################
121126
# #

env/netbox.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ REDIS_PASSWORD=H733Kdjndks81
2929
REDIS_SSL=false
3030
RELEASE_CHECK_URL=https://api.github.com/repos/netbox-community/netbox/releases
3131
SECRET_KEY='r(m)9nLGnz$(_q3N4z1k(EFsMCjjjzx08x9VhNVcfd%6RF#r!6DE@+V5Zk2X'
32+
API_TOKEN_PEPPER_1='Qy+F=OTeGskWQ(wTMgjc+NPPlz6YwFXY=KHIIg=wpYXT&e(6u8'
3233
SKIP_SUPERUSER=true
3334
WEBHOOKS_ENABLED=true

test-configuration/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
ALLOW_TOKEN_RETRIEVAL = True
1111

1212
DEFAULT_PERMISSIONS = {}
13+
14+
API_TOKEN_PEPPERS = {
15+
1: 'TEST-VALUE-DO-NOT-USE-TEST-VALUE-DO-NOT-USE-TEST-VALUE-DO-NOT-USE',
16+
}

0 commit comments

Comments
 (0)