django-DefectDojo icon indicating copy to clipboard operation
django-DefectDojo copied to clipboard

How can I do to recover admin password?

Open tsukiazuma opened this issue 1 year ago • 3 comments

When I remove all containers, images, cache,... and rebuild again. I not see admin password (old password admin is lost)

WARN[0000] The "DD_DATABASE_HOST" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_PORT" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_CELERY_BROKER_URL" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_URL" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_HOST" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_PORT" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_CELERY_BROKER_URL" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_URL" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_USER" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_PASSWORD" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_NAME" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_HOST" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_PORT" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_CELERY_BROKER_URL" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_URL" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_HOST" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_PORT" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_URL" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_NAME" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_USER" variable is not set. Defaulting to a blank string.
WARN[0000] The "DD_DATABASE_PASSWORD" variable is not set. Defaulting to a blank string.
django-defectdojo-initializer-1  | Admin password: Initialization detected that the admin user admin already exists in your database.

How can I do to recover admin password?

tsukiazuma avatar Jun 13 '24 02:06 tsukiazuma

See #10392

BTW, unless your DB is running in a container and you delete the volume that the DB container uses, it will persist in the DB which appears to be what happened here.

Also all those WARN[0000] lines don't look great - hopefully you've set those as ENV variables.

mtesauro avatar Jun 13 '24 02:06 mtesauro

Thank you very much. I can reset password. Can you guide detail me how to fix WARN[0000]?

tsukiazuma avatar Jun 13 '24 02:06 tsukiazuma

The reason I didn't say more about the WARN[000] is that there's not enough information in your issue to say more.

I can tell your using compose because of the error messages but not much more.

In general, those DD_[something] environmental variables are set in the environment where you launch compose or they could be hard coded into the compose file - both work.

Here's an example of a variable that expects DD_DATABASE_URL to already be set in the environment when you start compose: https://github.com/DefectDojo/django-DefectDojo/blob/master/docker-compose.yml#L53

If you look at setEnv.defectdojo and env.defectdojo in the community contrib repo, you'll see one option to set this before launching compose: https://github.com/DefectDojo/Community-Contribs/tree/master/CentOS-7-deploy/dojo

mtesauro avatar Jun 13 '24 13:06 mtesauro

Years later I found this page facing the same issue. Discovered in the docker logs that we can run this command to establish a new admin/password:

docker compose exe uwsgi /bin/bash -c 'python manage.py createsuperuser'

Thanks to the DefectDojo developer who added that python script and included the command in the docker logs. Very helpful!

delers447 avatar Oct 30 '25 17:10 delers447

@delers447 Please check the documentation for the easiest solution: https://github.com/DefectDojo/django-DefectDojo/blob/master/readme-docs/DOCKER.md#option-to-change-the-password

valentijnscholten avatar Oct 30 '25 19:10 valentijnscholten