Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run create_superuser to create super user on application's start #2333

Merged
merged 2 commits into from
Feb 9, 2023

Conversation

pbanaszkiewicz
Copy link
Contributor

This fixes #2310.

@pbanaszkiewicz pbanaszkiewicz added this to the v4.1 milestone Feb 7, 2023
@pbanaszkiewicz pbanaszkiewicz self-assigned this Feb 7, 2023
@pbanaszkiewicz pbanaszkiewicz added this to In progress in CI/CD for development branch via automation Feb 7, 2023
start.sh Show resolved Hide resolved
@pbanaszkiewicz
Copy link
Contributor Author

The idea here is to run create_superuser command when the container starts, so that admin user is created and we get to know their password.

I can see the CodeQL checks are complaining, so maybe I'll drop the password printing and accept the fact that new installation will have admin:admin superuser.

@pbanaszkiewicz
Copy link
Contributor Author

Added tests to make sure the command behaves like I want.

It will create the superuser account only if one doesn't exist. The existing superuser account will not be changed.

When moving this code to production, we can easily create account for user admin and disable it; this way the script doesn't do any harm.

@pbanaszkiewicz pbanaszkiewicz changed the title Repurpose create_superuser to also generate random password Run create_superuser to create super user on application's start Feb 7, 2023
Now the user account is created with the default password, if
and only if the account doesn't exist yet.
@pbanaszkiewicz
Copy link
Contributor Author

Conflict resolved. @elichad Can you review this PR?

@elichad
Copy link
Contributor

elichad commented Feb 9, 2023

When moving this code to production, we can easily create account for user admin and disable it; this way the script doesn't do any harm.

Is it worth creating that user now so we don't forget about it later?

@elichad
Copy link
Contributor

elichad commented Feb 9, 2023

Also, I haven't looked through the new CI/CD setup yet - is the database recreated from scratch every time the test server is re-deployed, or does it persist?

@pbanaszkiewicz
Copy link
Contributor Author

@elichad

Is it worth creating that user now so we don't forget about it later?

Good idea. I have just created this account on production server and disabled its permissions and access.
CC @maneesha @froggleston

Also, I haven't looked through the new CI/CD setup yet - is the database recreated from scratch every time the test server is re-deployed, or does it persist?

No, database persists. It is treated as a completely separate service from the application.

@pbanaszkiewicz pbanaszkiewicz merged commit f190a73 into develop Feb 9, 2023
CI/CD for development branch automation moved this from In progress to Done Feb 9, 2023
@pbanaszkiewicz pbanaszkiewicz deleted the feature/2310-create-super-admin branch February 10, 2023 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Prepare AMY staging instance for actual use
2 participants