diff --git a/docs/subsystems/auth.md b/docs/subsystems/auth.md index 0f32627b18..a3c09356d1 100644 --- a/docs/subsystems/auth.md +++ b/docs/subsystems/auth.md @@ -18,7 +18,13 @@ environment is to set up the real Google and GitHub to process auth requests for your development environment. The steps to do this are a variation of the steps documented in -`prod_settings_template.py`. Here are the full procedures for dev: +`prod_settings_template.py`. The main differences here are driven by +the fact that `dev_settings.py` is in Git, so it can be inconvenient +to put secrets there. In development, we allow providing those values +in the untracked file `zproject/dev-secrets.conf`, using the standard +lower-case naming convention for that file. + +Here are the full procedures for dev: ### Google @@ -47,9 +53,9 @@ The steps to do this are a variation of the steps documented in Specify `http://zulipdev.com:9991/complete/github/` as the callback URL. * You should get a page with settings for your new application, - showing a client ID and a client secret. In `dev_settings.py`, set - `SOCIAL_AUTH_GITHUB_KEY` to the client ID, and in - `dev-secrets.conf`, set `social_auth_github_secret` to the client secret. + showing a client ID and a client secret. In `dev-secrets.conf`, set + `social_auth_github_key` to the client ID and `social_auth_github_secret` + to the client secret. ### When SSL is required diff --git a/templates/zerver/config_error.html b/templates/zerver/config_error.html index 939bcb4079..da0491838d 100644 --- a/templates/zerver/config_error.html +++ b/templates/zerver/config_error.html @@ -53,7 +53,11 @@ {% endif %} {% if github_error %} - {{ render_markdown_path('zerver/github-error.md', {"root_domain_uri": root_domain_uri, "settings_path": settings_path, "secrets_path": secrets_path}) }} + {% if development_environment %} + {{ render_markdown_path('zerver/github-error.md', {"root_domain_uri": root_domain_uri, "settings_path": secrets_path, "secrets_path": secrets_path, "client_id_key_name": "social_auth_github_key"}) }} + {% else %} + {{ render_markdown_path('zerver/github-error.md', {"root_domain_uri": root_domain_uri, "settings_path": settings_path, "secrets_path": secrets_path, "client_id_key_name": "SOCIAL_AUTH_GITHUB_KEY"}) }} + {% endif %} {% endif %} {% if google_error or github_error %} diff --git a/templates/zerver/github-error.md b/templates/zerver/github-error.md index 18193d1beb..faef74b12e 100644 --- a/templates/zerver/github-error.md +++ b/templates/zerver/github-error.md @@ -5,7 +5,7 @@ You have added `{{ root_domain_uri }}/complete/github/` as the callback URL in the OAuth application in GitHub. You can create OAuth apps from [GitHub's developer site](https://github.com/settings/developers). -* You have set `SOCIAL_AUTH_GITHUB_KEY` in `{{ settings_path }}` and +* You have set `{{ client_id_key_name }}` in `{{ settings_path }}` and `social_auth_github_secret` in `{{ secrets_path }}` with the values from your OAuth application. diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py index 0a42de6b42..9102036891 100644 --- a/zerver/tests/test_docs.py +++ b/zerver/tests/test_docs.py @@ -342,7 +342,13 @@ class ConfigErrorTest(ZulipTestCase): self.assertEqual(result.status_code, 302) self.assertEqual(result.url, '/config-error/github') result = self.client_get(result.url) - self.assert_in_success_response(["SOCIAL_AUTH_GITHUB_KEY"], result) + self.assert_in_success_response(["social_auth_github_key"], result) + self.assert_in_success_response(["social_auth_github_secret"], result) + self.assert_in_success_response(["zproject/dev-secrets.conf"], result) + self.assert_not_in_success_response(["SOCIAL_AUTH_GITHUB_KEY"], result) + self.assert_not_in_success_response(["zproject/dev_settings.py"], result) + self.assert_not_in_success_response(["/etc/zulip/settings.py"], result) + self.assert_not_in_success_response(["/etc/zulip/zulip-secrets.conf"], result) @override_settings(SOCIAL_AUTH_GITHUB_KEY=None) @override_settings(DEVELOPMENT=False) @@ -352,7 +358,13 @@ class ConfigErrorTest(ZulipTestCase): self.assertEqual(result.status_code, 302) self.assertEqual(result.url, '/config-error/github') result = self.client_get(result.url) + self.assert_in_success_response(["SOCIAL_AUTH_GITHUB_KEY"], result) + self.assert_in_success_response(["/etc/zulip/settings.py"], result) + self.assert_in_success_response(["social_auth_github_secret"], result) self.assert_in_success_response(["/etc/zulip/zulip-secrets.conf"], result) + self.assert_not_in_success_response(["social_auth_github_key"], result) + self.assert_not_in_success_response(["zproject/dev_settings.py"], result) + self.assert_not_in_success_response(["zproject/dev-secrets.conf"], result) def test_smtp_error(self) -> None: result = self.client_get("/config-error/smtp")