Compare commits

...

10 commits

Author SHA1 Message Date
Dominic e6799ba214
Merge d6f8ae0281 into fd6a75ac96 2026-01-08 14:36:39 +01:00
Tobias Genannt fd6a75ac96
Support new API token format (#1591)
Some checks are pending
push / Builds new NetBox Docker Images (./build.sh feature, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh feature, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh main, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh main, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (PRERELEASE=true ./build-latest.sh, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (PRERELEASE=true ./build-latest.sh, ubuntu-24.04-arm) (push) Waiting to run
push / Checks syntax of our code (push) Waiting to run
push / Builds new NetBox Docker Images (./build-latest.sh, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (./build-latest.sh, ubuntu-24.04-arm) (push) Waiting to run
Support new API token format
2026-01-08 13:36:54 +01:00
Tobias Genannt 94dd752652
Merge pull request #1592 from netbox-community/renovate/sentry-sdk-2.x
Some checks are pending
push / Builds new NetBox Docker Images (./build.sh main, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (PRERELEASE=true ./build-latest.sh, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (PRERELEASE=true ./build-latest.sh, ubuntu-24.04-arm) (push) Waiting to run
push / Checks syntax of our code (push) Waiting to run
push / Builds new NetBox Docker Images (./build-latest.sh, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (./build-latest.sh, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh feature, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh feature, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh main, ubuntu-24.04) (push) Waiting to run
chore(deps): update dependency sentry-sdk to v2.49.0
2026-01-08 11:46:48 +01:00
renovate[bot] 20cccc3869
chore(deps): update dependency sentry-sdk to v2.49.0 2026-01-08 10:09:25 +00:00
Tobias Genannt 269cf83362
Merge pull request #1590 from netbox-community/renovate/granian-2.x
chore(deps): update dependency granian to v2.6.1
2026-01-08 09:18:35 +01:00
renovate[bot] da0784992e
chore(deps): update dependency granian to v2.6.1 2026-01-07 13:54:12 +00:00
Tobias Genannt c0ead010ec
Merge pull request #1571 from tobiasge/fix-pg-volume
Some checks are pending
push / Builds new NetBox Docker Images (./build.sh main, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (PRERELEASE=true ./build-latest.sh, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (PRERELEASE=true ./build-latest.sh, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh main, ubuntu-24.04) (push) Waiting to run
push / Checks syntax of our code (push) Waiting to run
push / Builds new NetBox Docker Images (./build-latest.sh, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (./build-latest.sh, ubuntu-24.04-arm) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh feature, ubuntu-24.04) (push) Waiting to run
push / Builds new NetBox Docker Images (./build.sh feature, ubuntu-24.04-arm) (push) Waiting to run
Changed volume to match upstream image
2026-01-07 14:53:42 +01:00
Tobias Genannt ebba20d02b Changed volume to match upstream image 2026-01-07 14:18:31 +01:00
Dominic d6f8ae0281
Update .gitignore
Formating
2025-08-30 13:19:01 +02:00
Dominic a517836bdd
Update .gitignore
add .env & Dockerfile-Plugins so user who build images with plugins don't get these local files tracked
2025-08-26 08:58:03 +02:00
7 changed files with 46 additions and 40 deletions

View file

@ -4,4 +4,4 @@ extend-ignore = E203, W503
per-file-ignores =
configuration/*:E131,E251,E266,E302,E305,E501,E722
startup_scripts/startup_script_utils/__init__.py:F401
docker/*:E266,E722
docker/*:E266,E722,E501

2
.gitignore vendored
View file

@ -12,3 +12,5 @@ configuration/ldap/*
!configuration/logging.py
!configuration/plugins.py
super-linter.log
.env
Dockerfile-Plugins

View file

@ -76,6 +76,7 @@ COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
COPY docker/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.py
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
COPY docker/super_user.py /opt/netbox/super_user.py
COPY configuration/ /etc/netbox/config/
COPY docker/granian.py /opt/netbox/netbox/netbox/granian.py
COPY VERSION /opt/netbox/VERSION

View file

@ -43,7 +43,7 @@ services:
retries: 5
env_file: env/postgres.env
volumes:
- netbox-postgres-data:/var/lib/postgresql/data
- netbox-postgres:/var/lib/postgresql
# redis
redis:
@ -75,7 +75,7 @@ services:
volumes:
netbox-media-files:
driver: local
netbox-postgres-data:
netbox-postgres:
driver: local
netbox-redis-cache-data:
driver: local

View file

@ -54,43 +54,10 @@ fi
if [ "$SKIP_SUPERUSER" == "true" ]; then
echo "↩️ Skip creating the superuser"
else
if [ -z ${SUPERUSER_NAME+x} ]; then
SUPERUSER_NAME='admin'
fi
if [ -z ${SUPERUSER_EMAIL+x} ]; then
SUPERUSER_EMAIL='admin@example.com'
fi
if [ -f "/run/secrets/superuser_password" ]; then
SUPERUSER_PASSWORD="$(</run/secrets/superuser_password)"
elif [ -z ${SUPERUSER_PASSWORD+x} ]; then
SUPERUSER_PASSWORD='admin'
fi
if [ -f "/run/secrets/superuser_api_token" ]; then
SUPERUSER_API_TOKEN="$(</run/secrets/superuser_api_token)"
elif [ -z ${SUPERUSER_API_TOKEN+x} ]; then
SUPERUSER_API_TOKEN='0123456789abcdef0123456789abcdef01234567'
fi
./manage.py shell --interface python <<END
from users.models import Token, User
if not User.objects.filter(username='${SUPERUSER_NAME}'):
u = User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}')
Token.objects.create(user=u, key='${SUPERUSER_API_TOKEN}')
END
echo "💡 Superuser Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}"
./manage.py shell --no-startup --no-imports --interface python \
</opt/netbox/super_user.py
fi
./manage.py shell --interface python <<END
from users.models import Token
try:
old_default_token = Token.objects.get(key="0123456789abcdef0123456789abcdef01234567")
if old_default_token:
print("⚠️ Warning: You have the old default admin API token in your database. This token is widely known; please remove it. Log in as your superuser and check API Tokens in your user menu.")
except Token.DoesNotExist:
pass
END
echo "✅ Initialisation is done."
# Launch whatever is passed by docker

36
docker/super_user.py Normal file
View file

@ -0,0 +1,36 @@
from os import environ
from django.conf import settings
from users.choices import TokenVersionChoices
from users.models import Token, User
# Read secret from file
def _read_secret(secret_name: str, default: str | None = None) -> str | None:
try:
f = open("/run/secrets/" + secret_name, "r", encoding="utf-8")
except EnvironmentError:
return default
else:
with f:
return f.readline().strip()
su_name = environ.get("SUPERUSER_NAME", "admin")
su_email = environ.get("SUPERUSER_EMAIL", "admin@example.com")
su_password = _read_secret("superuser_password", environ.get("SUPERUSER_PASSWORD", "admin"))
su_api_token = _read_secret(
"superuser_api_token",
environ.get("SUPERUSER_API_TOKEN", "0123456789abcdef0123456789abcdef01234567"),
)
if not User.objects.filter(username=su_name):
u = User.objects.create_superuser(su_name, su_email, su_password)
msg = ""
if not settings.API_TOKEN_PEPPERS:
print("⚠️ No API token will be created as API_TOKEN_PEPPERS is not set")
msg = f"💡 Superuser Username: {su_name}, E-Mail: {su_email}"
else:
t = Token.objects.create(user=u, token=su_api_token, version=TokenVersionChoices.V2)
msg = f"💡 Superuser Username: {su_name}, E-Mail: {su_email}, API Token: {t} (use with '{t.get_auth_header_prefix()}<Your token>')"
print(msg)

View file

@ -1,7 +1,7 @@
django-auth-ldap==5.3.0
dulwich==0.25.0
granian[uvloop]==2.6.0
granian[uvloop]==2.6.1
python3-saml==1.16.0
--no-binary lxml
--no-binary xmlsec
sentry-sdk[django]==2.48.0
sentry-sdk[django]==2.49.0