Merge pull request #955 from tobiasge/953-default-admin

Don't create superuser with default credentials
This commit is contained in:
Tobias Genannt 2023-03-15 14:20:07 +01:00 committed by GitHub
commit 480cabaefe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 12 deletions

View File

@ -47,12 +47,14 @@ docker compose up
The whole application will be available after a few minutes. The whole application will be available after a few minutes.
Open the URL `http://0.0.0.0:8000/` in a web-browser. Open the URL `http://0.0.0.0:8000/` in a web-browser.
You should see the NetBox homepage. You should see the NetBox homepage.
In the top-right corner you can login.
The default credentials are:
* Username: **admin** To create the first admin user run this command:
* Password: **admin**
* API Token: **0123456789abcdef0123456789abcdef01234567** ```bash
docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser
```
If you need to restart Netbox from an empty database often, you can also set the `SUPERUSER_*` variables in your `docker-compose.override.yml` as shown in the example.
[wiki-getting-started]: https://github.com/netbox-community/netbox-docker/wiki/Getting-Started [wiki-getting-started]: https://github.com/netbox-community/netbox-docker/wiki/Getting-Started

View File

@ -6,11 +6,18 @@ services:
# If you want the Nginx unit status page visible from the # If you want the Nginx unit status page visible from the
# outside of the container add the following port mapping: # outside of the container add the following port mapping:
# - "8001:8081" # - "8001:8081"
healthcheck: # healthcheck:
# Time for which the health check can fail after the container is started. # Time for which the health check can fail after the container is started.
# This depends mostly on the performance of your database. On the first start, # This depends mostly on the performance of your database. On the first start,
# when all tables need to be created the start_period should be higher than on # when all tables need to be created the start_period should be higher than on
# subsequent starts. For the first start after major version upgrades of NetBox # subsequent starts. For the first start after major version upgrades of NetBox
# the start_period might also need to be set higher. # the start_period might also need to be set higher.
# Default value in our docker-compose.yml is 60s # Default value in our docker-compose.yml is 60s
start_period: 90s # start_period: 90s
# environment:
# SKIP_SUPERUSER: "false"
# SUPERUSER_API_TOKEN: ""
# SUPERUSER_EMAIL: ""
# SUPERUSER_NAME: ""
# SUPERUSER_PASSWORD: ""

View File

@ -82,6 +82,13 @@ END
echo "💡 Superuser Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}" echo "💡 Superuser Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}"
fi fi
./manage.py shell --interface python <<END
from users.models import Token
old_default_token = Token.objects.get(key="0123456789abcdef0123456789abcdef01234567")
if old_default_token:
print("⚠️ Warning: You have the old default admin token in your database. This token is widely known; please remove it.")
END
echo "✅ Initialisation is done." echo "✅ Initialisation is done."
# Launch whatever is passed by docker # Launch whatever is passed by docker

6
env/netbox.env vendored
View File

@ -30,9 +30,5 @@ REDIS_PASSWORD=H733Kdjndks81
REDIS_SSL=false REDIS_SSL=false
RELEASE_CHECK_URL=https://api.github.com/repos/netbox-community/netbox/releases RELEASE_CHECK_URL=https://api.github.com/repos/netbox-community/netbox/releases
SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
SKIP_SUPERUSER=false SKIP_SUPERUSER=true
SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
SUPERUSER_EMAIL=admin@example.com
SUPERUSER_NAME=admin
SUPERUSER_PASSWORD=admin
WEBHOOKS_ENABLED=true WEBHOOKS_ENABLED=true