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

[DevOps] Generate a new, random DJANGO_SECRET_KEY on initial Cloud.gov deployments or rebuilds #967

Closed
5 tasks done
jtwillis92 opened this issue May 26, 2021 · 0 comments · Fixed by #1151
Closed
5 tasks done
Assignees
Milestone

Comments

@jtwillis92
Copy link

jtwillis92 commented May 26, 2021

Description:
Currently when an initial deployment is made to cloud.gov the DJANGO_SECRET_KEY environment variable is copied from Circle CI project settings and used for the deployed site. Since this variable is used for a number of key security features in Django it should be treated as highly sensitive and be distinct for each deployed environment.

We should instead automatically generate a random and secure token string to use for this value as part of the set-backend-env-vars.sh script. This could be done quite easily by calling python from the script and utilizing standard library functionality that was added in Python 3.6, as shown below:

DJANGO_SECRET_KEY=$(python -c "from secrets import token_urlsafe; print(token_urlsafe(50))")

echo $DJANGO_SECRET_KEY                                                                                                                                                                                       
DowPrP19r5_nxNhEPkHfjILJ-3igR5KFqQ1vztlyQzR62-T6z3mohJOtGCGA3LUHb7I

As a stretch goal, if we provide a reasonable default for this setting in local and CI contexts we could remove it entirely from Circle CI. This default should never be allowed for use in production contexts though so we would only want to define it in the local.py settings module.

Acceptance Criteria:

  • DJANGO_SECRET_KEY is automatically generated for initial deployments to Cloud.gov
  • Testing Checklist has been run and all tests pass
  • README is updated, if necessary

Tasks:

  • Update set-backend-env-vars.sh to generate a new DJANGO_SECRET_KEY instead of passing in the one from Circle CI
  • Run Testing Checklist and confirm all tests pass

Notes:

Supporting Documentation:

Open Questions:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants