Skip to content

Commit 9cc5721

Browse files
authored
Move documentation from sphinx to mkdocs (#178)
1 parent b6b3715 commit 9cc5721

28 files changed

+470
-506
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ jobs:
2727
- uses: actions/setup-python@v6
2828
with:
2929
python-version: "3.11"
30-
- run: sudo apt-get update && sudo apt-get install -y gettext python3-enchant
31-
- run: python -m pip install sphinxcontrib-spelling
30+
- run: sudo apt-get update && sudo apt-get install -y gettext
3231
- run: python -m pip install -e '.[docs]'
33-
- run: python -m sphinx -W -b spelling docs docs/_build
32+
- run: python -m mkdocs build --strict
3433
SQLite:
3534
needs: [dist, docs]
3635
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ docs/_build/
5757
# PyBuilder
5858
target/
5959

60-
60+
# mkdocs documentation
61+
/site/
6162

6263
tests/local.py
6364
docs/_build/

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ repos:
2626
hooks:
2727
- id: mdformat
2828
additional_dependencies:
29-
- mdformat-ruff
3029
- mdformat-ruff
3130
- mdformat-footnote
3231
- mdformat-gfm

.readthedocs.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
44
version: 2
55
build:
6-
os: ubuntu-20.04
6+
os: ubuntu-24.04
77
tools:
8-
python: "3.11"
9-
sphinx:
10-
configuration: docs/conf.py
8+
python: "3"
9+
mkdocs:
10+
configuration: mkdocs.yml
1111
python:
1212
install:
1313
- method: pip

README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<p align="center">
2+
<picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/codingjoe/django-mail-auth/raw/main/images/logo-dark.svg">
4+
<source media="(prefers-color-scheme: light)" srcset="https://github.com/codingjoe/django-mail-auth/raw/main/images/logo-light.svg">
5+
<img alt="Django MailAuth: Secure login links; no passwords required!" src="https://github.com/codingjoe/django-mail-auth/raw/main/images/logo-light.svg">
6+
</picture>
7+
</p>
8+
9+
# Django Mail Auth
10+
11+
[![version](https://img.shields.io/pypi/v/django-mail-auth.svg)](https://pypi.python.org/pypi/django-mail-auth/)
12+
[![Documentation Status](https://readthedocs.org/projects/django-mail-auth/badge/?version=latest)](https://django-mail-auth.readthedocs.io/en/latest/?badge=latest)
13+
[![coverage](https://codecov.io/gh/codingjoe/django-mail-auth/branch/main/graph/badge.svg)](https://codecov.io/gh/codingjoe/django-mail-auth)
14+
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/codingjoe/django-mail-auth/main/LICENSE)
15+
16+
Django Mail Auth is a lightweight authentication backend for Django,
17+
that does not require users to remember passwords.
18+
19+
Django Mail Auth features:
20+
21+
- custom user model support
22+
- drop in Django admin support
23+
- drop in Django User replacement
24+
- drop in Wagtail login replacement
25+
- extendable SMS support
26+
27+
![](sample.png){alt="screenshot from a login form" width="425px"}
28+
29+
This project was inspired by:
30+
31+
- [Is it time for password-less login?](http://notes.xoxco.com/post/27999787765/is-it-time-for-password-less-login)
32+
by [Ben Brown](http://twitter.com/benbrown)
33+
- [LOGIN WITHOUT PASSWORD MOST SECURE | WAIT.. WHAT?](https://www.lucius.digital/en/blog/login-without-password-most-secure-wait-what)
34+
by [Joris Snoek](https://twitter.com/lucius_digital)
35+
- [django-nopassword](https://github.com/relekang/django-nopassword) by
36+
[Rolf Erik Lekang](http://rolflekang.com)
37+
38+
## Installation
39+
40+
Run this command to install `django-mail-auth`:
41+
42+
```
43+
python3 -m pip install django-mail-auth[wagtail]
44+
```
45+
46+
## Setup
47+
48+
First add `mailauth` to you installed apps:
49+
50+
```python
51+
INSTALLED_APPS = [
52+
# Django's builtin apps…
53+
"mailauth",
54+
"mailauth.contrib.admin", # optional
55+
"mailauth.contrib.user", # optional
56+
# optional, must be included before "wagtail.admin"
57+
"mailauth.contrib.wagtail",
58+
# other apps…
59+
]
60+
```
61+
62+
`mailauth.contrib.admin` is optional and will replace the admin's login
63+
with token based authentication too.
64+
65+
`mailauth.contrib.user` is optional and provides a new Django User
66+
model. The new User model needs to be enabled via the `AUTH_USER_MODEL`
67+
setting:
68+
69+
```python
70+
# This setting should be either "EmailUser" or
71+
# any custom subclass of "AbstractEmailUser"
72+
AUTH_USER_MODEL = "mailauth_user.EmailUser"
73+
74+
# optional, Wagtail only
75+
WAGTAILUSERS_PASSWORD_ENABLED = False
76+
```
77+
78+
Next you will need to add the new authentication backend:
79+
80+
```python
81+
AUTHENTICATION_BACKENDS = (
82+
# default, but now optional
83+
# This should be removed if you use mailauth.contrib.user or any other
84+
# custom user model that does not have a username/password
85+
"django.contrib.auth.backends.ModelBackend",
86+
# The new access token based authentication backend
87+
"mailauth.backends.MailAuthBackend",
88+
)
89+
```
90+
91+
Django's `ModelBackend` is only needed, if you still want to support
92+
password based authentication. If you don't, simply remove it from the
93+
list.
94+
95+
Last but not least, go to your URL root configuration `urls.py` and add
96+
the following:
97+
98+
```python
99+
from django.urls import path
100+
101+
102+
urlpatterns = [
103+
path("accounts/", include("mailauth.urls")),
104+
# optional, must be before "wagtail.admin.urls"
105+
path("", include("mailauth.contrib.wagtail.urls")),
106+
]
107+
```
108+
109+
That's it!
110+
111+
> [!IMPORTANT]
112+
> Don't forget to setup you Email backend!

README.rst

Lines changed: 0 additions & 124 deletions
This file was deleted.

docs/conf.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

docs/contributing.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contributing
2+
3+
To run test suite run:
4+
5+
```console
6+
uv run pytest
7+
```
8+
9+
To build the documentation run:
10+
11+
```
12+
uv run mkdocs serve
13+
```
14+
15+
## The sample app
16+
17+
To run a full example --- e.g. to debug frontend code -- you can run:
18+
19+
```
20+
uv run tests/manage.py migrate
21+
uv run tests/manage.py createsuperuser
22+
# You will be asked for the email address of your new superuser
23+
uv run tests/manage.py runserver
24+
```
25+
26+
Next you can go to <https://localhost:8000/admin/> and log in with your
27+
newly created superuser.

docs/contributing.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)