Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ insert_final_newline = true
charset = utf-8
end_of_line = lf

[*.{json,yml,yaml,js,jsx}]
[*.{json,yml,yaml,js,jsx,toml}]
indent_size = 2

[*.{html,htm}]
Expand Down
93 changes: 43 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,32 @@ jobs:
fail-fast: false
matrix:
lint-command:
- "bandit -r mailauth -x tests"
- "black --check --diff ."
- "flake8 ."
- "isort --check-only --diff ."
- "pydocstyle ."
- bandit -r . -x ./tests
- black --check --diff .
- flake8 .
- isort --check-only --diff .
- pydocstyle .
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- run: python -m pip install -r requirements.txt
cache: pip
cache-dependency-path: linter-requirements.txt
- run: python -m pip install -r linter-requirements.txt
- run: ${{ matrix.lint-command }}

dist:
runs-on: ubuntu-latest
steps:
- run: sudo apt install -y gettext
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: actions/checkout@v3
- name: Install Python dependencies
run: python -m pip install --upgrade pip setuptools wheel twine readme-renderer
- run: python setup.py sdist bdist_wheel
run: python -m pip install --upgrade pip build wheel twine readme-renderer
- run: python -m build --sdist --wheel
- run: python -m twine check dist/*
- uses: actions/upload-artifact@v3
with:
Expand All @@ -51,16 +50,14 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- run: python -m pip install --upgrade pip setuptools wheel
- run: python -m pip install -r requirements.txt
- run: python setup.py develop
- run: python setup.py build_sphinx -W
python-version: "3.11"
- run: sudo apt install -y python3-enchant
- run: python -m pip install sphinxcontrib-spelling
- run: python -m pip install -e '.[docs]'
- run: python -m sphinx -W -b spelling docs docs/_build

SQLite:
needs: [lint, dist, docs]
needs: [ lint, dist, docs ]
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -69,50 +66,48 @@ jobs:
- "3.10"
- "3.11"
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install --upgrade pip setuptools wheel
- uses: actions/checkout@v3
- run: python setup.py test
- name: Codecov
run: |
python -m pip install codecov
codecov
- run: python -m pip install -e '.[test]'
- run: python -m pytest
- uses: codecov/codecov-action@v2
with:
flags: ${{ matrix.python-version }}

extras:
needs: [lint, dist, docs]
contrib:
needs: [ lint, dist, docs ]
runs-on: ubuntu-latest
strategy:
matrix:
extras:
- wagtail
python-version: ["3.x"]
python-version: [ "3.x" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install --upgrade pip setuptools wheel
- uses: actions/checkout@v3
- run: python -m pip install -e ".[${{ matrix.extras }}]"
- run: python setup.py test
- name: Codecov
run: |
python -m pip install codecov
codecov
- run: python -m pip install -e ".[test,${{ matrix.extras }}]"
- run: python -m pytest
- uses: codecov/codecov-action@v2
with:
flags: ${{ matrix.extras }}


PostgreSQL:
needs: [lint, dist, docs]
needs: [ lint, dist, docs ]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: [ "3.10" ]
django-version:
- "4.0"
- "4.1"
extras:
- postgres
services:
postgres:
image: postgres
Expand All @@ -127,21 +122,19 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install --upgrade pip setuptools wheel
- uses: actions/checkout@v3
- run: python -m pip install "psycopg2-binary<2.9" Django~=${{ matrix.django-version }}.0
- run: python setup.py test
- run: python -m pip install Django~=${{ matrix.django-version }}.0 -e ".[test,${{ matrix.extras }}]"
- run: python -m pytest
env:
DB_PORT: ${{ job.services.postgres.ports[5432] }}
DB: pg
- name: Codecov
run: |
python -m pip install codecov
codecov
- uses: codecov/codecov-action@v2
with:
flags: ${{ matrix.extras }}

analyze:
name: CodeQL
needs: [SQLite, extras, PostgreSQL]
needs: [ SQLite, contrib, PostgreSQL ]
runs-on: ubuntu-latest
permissions:
actions: read
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Python dependencies
run: python -m pip install --upgrade pip setuptools wheel twine
- name: Build dist packages
run: python setup.py sdist bdist_wheel
- name: Upload packages
run: python -m twine upload dist/*
- run: python -m pip install --upgrade pip build wheel twine
- run: python -m build --sdist --wheel
- run: python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ tests/local.py
docs/_build/
venv
.python-version
_version.py
20 changes: 20 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-20.04
tools:
python: "3.11"

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .
extra_requirements:
- docs
15 changes: 4 additions & 11 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,22 @@ Contributing

To install the development requirements simply run::

python setup.py develop
python -m pip install -e '.[test]'

To run test suite run::

python setup.py test

... and to run the entire test suite, simply use tox::

pip install --upgrade tox
tox
python -m pytest

To build the documentation run::

python setup.py build_sphinx
open docs/_build/html/index.html

python -m sphinx -W -b spelling docs docs/_build

The sample app
==============

To run a full example — e.g. to debug frontend code – you can run::

python setup.py develop
python -m pip install -e .
python tests/testapp/manage.py migrate
python tests/testapp/manage.py createsuperuser
# You will be asked for the email address of your new superuser
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Next you will need to add the new authentication backend::
Django's ``ModelBackend`` is only needed, if you still want to support
password based authentication. If you don't, simply remove it from the list.

Last but not least, go to your URL root config ``urls.py`` and add the following::
Last but not least, go to your URL root configuration ``urls.py`` and add the following::

from django.urls import path

Expand Down
7 changes: 7 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Security Policy

## Security contact information

To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
12 changes: 11 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
django.setup()

project = "Django Mail Auth"
copyright = "2019, Johannes Hoppe"
copyright = "2022, Johannes Maron"
release = get_distribution("django-mail-auth").version
version = ".".join(release.split(".")[:2])

Expand All @@ -31,6 +31,16 @@
),
}

try:
import sphinxcontrib.spelling # noqa

Check notice

Code scanning / CodeQL

Unused import

Import of 'sphinxcontrib' is not used.
except ImportError:
pass
else:
extensions.append("sphinxcontrib.spelling")

spelling_word_list_filename = "spelling_wordlist.txt"

Check notice

Code scanning / CodeQL

Unused global variable

The global variable 'spelling_word_list_filename' is not used.
spelling_show_suggestions = True

Check notice

Code scanning / CodeQL

Unused global variable

The global variable 'spelling_show_suggestions' is not used.


autodoc_default_options = {
"show-inheritance": True,
Expand Down
4 changes: 2 additions & 2 deletions docs/customizing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Custom login form
Custom login forms need to inherit from :class:`.BaseLoginForm` and override
the :meth:`save<.BaseLoginForm.save>` method.

The following example is for a login SMS via twilio. This will require a
The following example is for a login SMS. This will require a
custom user model with a unique ``phone_number`` field::

from django import forms
Expand Down Expand Up @@ -58,7 +58,7 @@ custom user model with a unique ``phone_number`` field::
)


To add the new login form, simply add a new login view to your URL config with
To add the new login form, simply add a new login view to your URL configuration with
the custom form::

from django.urls import path
Expand Down
17 changes: 17 additions & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
admin
anonymize
anonymized
anonymization
Auth
boolean
backend
Django
frontend
mixin
mixins
namespace
subclasses
tuple
tuples
triple
URL
4 changes: 1 addition & 3 deletions requirements.txt → linter-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Django>=2.2
Wagtail>=2.8
bandit==1.7.4
black==22.10.0
flake8==5.0.4
isort==5.10.1
pydocstyle==6.1.1
pydocstyle[toml]==6.1.1
6 changes: 5 additions & 1 deletion mailauth/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
"""Django authentication via login urls, no password required."""
"""Django authentication via login URLs, no passwords required."""
from . import _version

Check notice

Code scanning / CodeQL

Module imports itself

The module 'mailauth' imports itself.

__version__ = _version.version
VERSION = _version.version_tuple
13 changes: 6 additions & 7 deletions mailauth/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ def get_mail_context(self, request, user):
Returns:
dict:
A context dictionary including:

- site
- site_name
- token
- login_url
- user
- ``site``
- ``site_name``
- ``token``
- ``login_url``
- ``user``

"""
token = self.get_token(user)
Expand All @@ -79,7 +78,7 @@ def save(self):
Called from the login view, if the form is valid.

This method must be implemented by subclasses. This method
should trigger the login url to be sent to the user.
should trigger the login URL to be sent to the user.
"""
raise NotImplementedError

Expand Down
Loading