Skip to content

Commit 0caaa5a

Browse files
authored
Drop custom separator in favor of default colon (:) (#28)
* Drop custom separator in favor of default colon (`:`) Dot is unreserved character, however the representation in browsers (`%2E` or `.`), mail clients and even SMTP-servers is not unified and can lead to different issues: - https://wordtothewise.com/2018/11/why-do-my-urls-have-two-dots/ - https://bugs.python.org/issue43922 Also, Django is using dot for some funky JSON compression in `django.core.signing`: https://github.com/django/django/blob/4f8c7fd9d91b35e2c2922de4bb50c8c8066cbbc6/django/core/signing.py#L29-L30 So, in this PR I am suggesting to drop custom separator and switch to the default colon (`:`). It is also not reserved of anything in domain path, but only in host and scheme parts. - https://www.rfc-editor.org/rfc/rfc3986#section-3.3 - https://security.stackexchange.com/questions/159099/colons-in-urls-safe * Change token * Pin psycopg2-binary<2.9 in CI Django versions <3 have no compatibility with psycopg-binary>=2.9. django/django#14530 I'd be up for dropping Django 2.2 completely, as it is now only receiving security support, but we also can wait until April and simply pin psycopg-binary in CI until then (as I would not expect anything breaking because of that). * Fix token for Django 2.2
1 parent 563e4e3 commit 0caaa5a

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
python-version: ${{ matrix.python-version }}
128128
- run: python -m pip install --upgrade pip setuptools wheel
129129
- uses: actions/checkout@v2.4.0
130-
- run: python -m pip install psycopg2-binary Django~=${{ matrix.django-version }}
130+
- run: python -m pip install "psycopg2-binary<2.9" Django~=${{ matrix.django-version }}
131131
- run: python setup.py test
132132
env:
133133
DB_PORT: ${{ job.services.postgres.ports[5432] }}

mailauth/signing.py

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ class UserDoesNotExist(signing.BadSignature):
2525
class UserSigner(signing.TimestampSigner):
2626
"""Issue and verify URL safe access tokens for users."""
2727

28-
def __init__(self, key=None, sep=".", salt=None):
29-
super().__init__(key=key, sep=sep, salt=salt)
30-
3128
@staticmethod
3229
def to_timestamp(value):
3330
"""

tests/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def admin_user(db):
3838
def signature():
3939
"""Return a signature matching the user fixture."""
4040
if django.VERSION < (3, 1):
41-
return "LZ.173QUS.1Hjptg.lf2hFgOXQtjQsFypS2ItRG2hkpA"
42-
return "LZ.173QUS.1Hjptg.UtFdkTPoyrSA0IB6AUEhtz_hMyFZY0kcREE1HnWdFq4"
41+
return "LZ:173QUS:1Hjptg:umUR9iKN1rxDezT-dZGwqcqsM5Y"
42+
return "LZ:173QUS:1Hjptg:6oq5DS1NJ7SxJ1o-CpfgaqrImVaRpkcHrzV9yltwcHM"
4343

4444

4545
@pytest.fixture()

0 commit comments

Comments
 (0)