From bfcdfea6c855d8b21e1dfc214e44e75fec45f837 Mon Sep 17 00:00:00 2001 From: colcrunch Date: Tue, 1 Dec 2020 17:17:55 -0500 Subject: [PATCH 1/5] Update minimum django-esi version to ensure support for `user-agent` header. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e58e7591..94e6d473 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ install_requires = [ 'sleekxmpp', 'pydiscourse', - 'django-esi>=1.5,<3.0' + 'django-esi>=2.0.4,<3.0' ] testing_extras = [ From 75de4518f24b7f2e910bed8ce088923e35c42a04 Mon Sep 17 00:00:00 2001 From: colcrunch Date: Tue, 1 Dec 2020 22:40:09 -0500 Subject: [PATCH 2/5] Use `app_info_text` in `EveSwaggerProvider` to set the `User-Agent` header on ESI requests. --- allianceauth/eveonline/providers.py | 6 ++++-- allianceauth/eveonline/tests/test_providers.py | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/allianceauth/eveonline/providers.py b/allianceauth/eveonline/providers.py index 3cff9567..dc25ba35 100644 --- a/allianceauth/eveonline/providers.py +++ b/allianceauth/eveonline/providers.py @@ -7,6 +7,8 @@ from jsonschema.exceptions import RefResolutionError from django.conf import settings from esi.clients import esi_client_factory +from allianceauth import __version__ + SWAGGER_SPEC_PATH = os.path.join(os.path.dirname( os.path.abspath(__file__)), 'swagger.json' @@ -166,7 +168,7 @@ class EveSwaggerProvider(EveProvider): else: try: self._client = esi_client_factory( - token=token, spec_file=SWAGGER_SPEC_PATH + token=token, spec_file=SWAGGER_SPEC_PATH, app_info_text=("allianceauth v" + __version__) ) except (HTTPError, RefResolutionError): logger.exception( @@ -182,7 +184,7 @@ class EveSwaggerProvider(EveProvider): def client(self): if self._client is None: self._client = esi_client_factory( - token=self._token, spec_file=SWAGGER_SPEC_PATH + token=self._token, spec_file=SWAGGER_SPEC_PATH, app_info_text=("allianceauth v" + __version__) ) return self._client diff --git a/allianceauth/eveonline/tests/test_providers.py b/allianceauth/eveonline/tests/test_providers.py index fa09c36a..48697168 100644 --- a/allianceauth/eveonline/tests/test_providers.py +++ b/allianceauth/eveonline/tests/test_providers.py @@ -592,3 +592,12 @@ class TestEveSwaggerProvider(TestCase): self.assertTrue(mock_esi_client_factory.called) self.assertIsNotNone(my_provider._client) self.assertEqual(my_client, 'my_client') + + @patch(MODULE_PATH + '.__version__', '1.0.0') + def test_user_agent_header(self): + my_provider = EveSwaggerProvider() + my_client = my_provider.client + operation = my_client.Status.get_status() + self.assertEqual( + operation.future.request.headers['User-Agent'], 'allianceauth v1.0.0' + ) From 35ae710624a172d4ee78be7c8f0ecbf72f56aa37 Mon Sep 17 00:00:00 2001 From: colcrunch Date: Tue, 1 Dec 2020 23:25:48 -0500 Subject: [PATCH 3/5] Add `ESI_USER_CONTACT_EMAIL` setting to local.py --- allianceauth/project_template/project_name/settings/local.py | 1 + 1 file changed, 1 insertion(+) diff --git a/allianceauth/project_template/project_name/settings/local.py b/allianceauth/project_template/project_name/settings/local.py index 8761facb..45d16881 100644 --- a/allianceauth/project_template/project_name/settings/local.py +++ b/allianceauth/project_template/project_name/settings/local.py @@ -45,6 +45,7 @@ DATABASES['default'] = { ESI_SSO_CLIENT_ID = '' ESI_SSO_CLIENT_SECRET = '' ESI_SSO_CALLBACK_URL = '' +ESI_USER_CONTACT_EMAIL = '' # By default emails are validated before new users can log in. # It's recommended to use a free service like SparkPost or Elastic Email to send email. From bccead08819af2de61a92a43b9ca94b067452746 Mon Sep 17 00:00:00 2001 From: colcrunch Date: Wed, 2 Dec 2020 17:42:03 -0500 Subject: [PATCH 4/5] Add mention of `ESI_USER_CONTACT_EMAIL` to install documentation. --- docs/installation/allianceauth.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/installation/allianceauth.md b/docs/installation/allianceauth.md index 4e19b648..4e2b084a 100644 --- a/docs/installation/allianceauth.md +++ b/docs/installation/allianceauth.md @@ -181,6 +181,8 @@ For **scopes** your SSO app needs to have at least `publicData`. Additional scop As **callback URL** you want to define the URL of your Alliance Auth site plus the route: `/sso/callback`. Example for a valid callback URL: `https://auth.example.com/sso/callback` +In `local.py` you will need to set `ESI_USER_CONTACT_EMAIL` to an email address to ensure that CCP has reliable contact information for you. + ### Alliance Auth Project Ensure wheel is available before continuing: From cb40649f8bb1cb4b73fe569e33352b497c33fd77 Mon Sep 17 00:00:00 2001 From: colcrunch Date: Sun, 6 Dec 2020 22:54:31 -0500 Subject: [PATCH 5/5] Add note to local.py on `ESI_CONTACT_EMAIL` setting --- allianceauth/project_template/project_name/settings/local.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/allianceauth/project_template/project_name/settings/local.py b/allianceauth/project_template/project_name/settings/local.py index 45d16881..7bca8736 100644 --- a/allianceauth/project_template/project_name/settings/local.py +++ b/allianceauth/project_template/project_name/settings/local.py @@ -45,7 +45,7 @@ DATABASES['default'] = { ESI_SSO_CLIENT_ID = '' ESI_SSO_CLIENT_SECRET = '' ESI_SSO_CALLBACK_URL = '' -ESI_USER_CONTACT_EMAIL = '' +ESI_USER_CONTACT_EMAIL = '' # A server maintainer that CCP can contact in case of issues. # By default emails are validated before new users can log in. # It's recommended to use a free service like SparkPost or Elastic Email to send email.