Tested on brand new machines, made a few minor docs tweaks and adjustments for findings, but generally went well so I'm merging this.
3.8 KiB
Social Login with django-allauth
Follow these instructions to use the social logins through django-allauth on your local machine.
See https://testdriven.io/blog/django-social-auth/ for more information.
Github
- Go to https://github.com/settings/applications/new and add a new OAuth application
- Set
http://localhost:8000as the Homepage URL - Set
http://localhost:8000/accounts/github/login/callback/as the Callback URL - Click whether you want to enable the device flow
- On completion copy the Client ID and Client Secret to the
.envfile as values ofGITHUB_OAUTH_CLIENT_IDandGITHUB_OAUTH_CLIENT_SECRET. - Run
direnv allowand restart your docker containers.
Setup should be complete and you should be able to see an option to "Use Github" on the sign up page.
To test the flow including authorizing Github for the Boost account, log into your GitHub account settings and click Applications in the left menu. Find the "Boost" authorization and delete it. The next time you log into Boost with this GitHub account, you will have to re-authorize it.
This setup process is not something that can currently be automated through terraform because of a lack of relevant Github API endpoints to create Oauth credentials.
More detailed instructions at:
https://docs.allauth.org/en/latest/socialaccount/providers/google.html
- Update the
.envfile with values for:TF_VAR_google_cloud_email(the email address of your Google Cloud account)TF_VAR_google_organization_domain(usually the domain of your Google Cloud account, e.g. "boost.org" if you will be using a @boost.org email address)TF_VAR_google_cloud_project_name(optional, default: localboostdev) - needs to change if destroyed and a setup is needed within 30 days
- Run
just development-tofu-initto initialize tofu. - Run
just development-tofu-planto confirm the planned changes. - Run
just development-tofu-applyto apply the changes. - Go to https://console.developers.google.com/
- Search for the newly created project, named "Boost Development" (ID: localboostdev by default).
- Type "credentials" in the search input at the top of the page.
- Select "Credentials" under "APIs & Services".
- Click "+ CREATE CREDENTIALS"
- Select "OAuth Client ID"
- Select Application Type: "Web application"
- Name: "Boost Development" (arbitrary)
- For "Authorized Javascript Origins" use:
http://localhost:8000 - For "Authorized Redirect URIs" use:
http://localhost:8000/accounts/google/login/callback/http://localhost:8000/accounts/google/login/callback/?flowName=GeneralOAuthFlow
- Save
- From the page that's displayed, update the
.envfile with values for the following:GOOGLE_OAUTH_CLIENT_IDshould be similar to "k235bn2b1l1(...)asdsk.apps.googleusercontent.com"GOOGLE_OAUTH_CLIENT_SECRETshould be similar to "LAJACO(...)KLAI612ANAD"
Point 5 above can not be automated through terraform because of a lack of relevant Google Cloud API endpoints to create Oauth credentials.
Setup should be complete and you should be able to see an option to "Use Google" on the sign up page.
Additional Notes on allauth login flows:
Working locally: If you need to run through the login flows multiple times, create a superuser so you can log into the admin. Then, log into the admin and delete your "Social Account" from the admin. This will test a fresh connection to GitHub for your logged-in GitHub user.
