django-solomon 0.1.3__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_solomon-0.3.0/CHANGELOG.md +57 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/PKG-INFO +21 -4
- {django_solomon-0.1.3 → django_solomon-0.3.0}/README.md +20 -3
- django_solomon-0.3.0/docs/contributing.md +138 -0
- django_solomon-0.3.0/docs/installation.md +174 -0
- django_solomon-0.3.0/docs/settings.md +208 -0
- django_solomon-0.3.0/docs/templates.md +256 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/justfile +3 -3
- {django_solomon-0.1.3 → django_solomon-0.3.0}/mkdocs.yml +4 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/pyproject.toml +1 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/backends.py +16 -0
- django_solomon-0.3.0/src/django_solomon/migrations/0002_magiclink_ip_address.py +18 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/models.py +3 -2
- django_solomon-0.3.0/src/django_solomon/utilities.py +150 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/views.py +7 -2
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/test_backends.py +58 -1
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/test_utilities.py +205 -1
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tox.ini +2 -1
- {django_solomon-0.1.3 → django_solomon-0.3.0}/uv.lock +24 -0
- django_solomon-0.1.3/CHANGELOG.md +0 -1
- django_solomon-0.1.3/src/django_solomon/utilities.py +0 -81
- {django_solomon-0.1.3 → django_solomon-0.3.0}/.forgejo/workflows/release.yml +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/.forgejo/workflows/tests.yml +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/.gitignore +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/.pre-commit-config.yaml +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/.readthedocs.yml +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/LICENSE +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/docs/changelog.md +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/docs/index.md +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/docs/requirements.txt +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/__init__.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/admin.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/apps.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/config.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/forms.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/locale/de/LC_MESSAGES/django.po +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/locale/en/LC_MESSAGES/django.po +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/management/__init__.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/management/commands/__init__.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/migrations/0001_initial.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/migrations/__init__.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/py.typed +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/templates/django_solomon/base/invalid_magic_link.html +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/templates/django_solomon/base/login_form.html +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/templates/django_solomon/base/magic_link_sent.html +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/templates/django_solomon/email/magic_link.mjml +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/templates/django_solomon/email/magic_link.txt +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/src/django_solomon/urls.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/.gitignore +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/__init__.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/conftest.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/settings.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/templates/base.html +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/test_admin.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/test_config.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/test_forms.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/test_models.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/test_urls.py +0 -0
- {django_solomon-0.1.3 → django_solomon-0.3.0}/tests/test_views.py +0 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to django-solomon will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [0.3.0] - 2025-04-20
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- IP address tracking for magic links
|
13
|
+
- IP validation to enhance security (optional via `SOLOMON_ENFORCE_SAME_IP` setting)
|
14
|
+
- Privacy-focused IP anonymization (enabled by default via `SOLOMON_ANONYMIZE_IP` setting)
|
15
|
+
- New utility functions for IP handling and anonymization
|
16
|
+
|
17
|
+
### Security
|
18
|
+
|
19
|
+
- Option to validate magic links are used from the same IP address they were created from
|
20
|
+
- IP anonymization to protect user privacy (removes last octet for IPv4, last 80 bits for IPv6)
|
21
|
+
|
22
|
+
## [0.2.0] - 2025-04-19
|
23
|
+
|
24
|
+
### Added
|
25
|
+
|
26
|
+
- Comprehensive guides for usage and contribution
|
27
|
+
- Parallel test execution with pytest-xdist
|
28
|
+
- Link to official documentation in README
|
29
|
+
- New badges to README
|
30
|
+
- Initial changelog structure
|
31
|
+
|
32
|
+
### Changed
|
33
|
+
|
34
|
+
- Improved documentation organization
|
35
|
+
|
36
|
+
## [0.1.3] - 2025-04-19
|
37
|
+
|
38
|
+
### Added
|
39
|
+
|
40
|
+
- Initial public release of django-solomon
|
41
|
+
- Passwordless authentication using magic links sent via email
|
42
|
+
- Configurable link expiration time (default: 300 seconds)
|
43
|
+
- Blacklist functionality to block specific email addresses
|
44
|
+
- Support for auto-creating users when they request a magic link
|
45
|
+
- Customizable templates for emails and pages
|
46
|
+
- MJML support for HTML emails
|
47
|
+
- Compatible with Django's authentication system
|
48
|
+
- Support for Django 4.2, 5.0, 5.1, and 5.2
|
49
|
+
- Support for Python 3.10, 3.11, 3.12, and 3.13
|
50
|
+
- Comprehensive test suite with high code coverage
|
51
|
+
- Full documentation
|
52
|
+
|
53
|
+
### Security
|
54
|
+
|
55
|
+
- One-time use magic links
|
56
|
+
- Option to allow only one active magic link per user
|
57
|
+
- Configurable permissions for admin and staff users
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: django-solomon
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: A Django app for passwordless authentication using magic links.
|
5
5
|
Project-URL: Home, https://django-solomon.rtfd.io/
|
6
6
|
Project-URL: Documentation, https://django-solomon.rtfd.io/
|
@@ -55,6 +55,8 @@ Description-Content-Type: text/markdown
|
|
55
55
|
[](https://pypi.org/project/django-solomon/)
|
56
56
|
[](https://pypi.org/project/django-solomon/)
|
57
57
|
[](https://django-solomon.rtfd.io/en/latest/?badge=latest)
|
58
|
+
[](https://github.com/astral-sh/ruff)
|
59
|
+
[](https://github.com/astral-sh/uv)
|
58
60
|
|
59
61
|
A Django app for passwordless authentication using magic links.
|
60
62
|
|
@@ -64,6 +66,8 @@ A Django app for passwordless authentication using magic links.
|
|
64
66
|
- Configurable link expiration time
|
65
67
|
- Blacklist functionality to block specific email addresses
|
66
68
|
- Support for auto-creating users when they request a magic link
|
69
|
+
- IP address tracking and validation for enhanced security
|
70
|
+
- Privacy-focused IP anonymization
|
67
71
|
- Customizable templates for emails and pages
|
68
72
|
- Compatible with Django's authentication system
|
69
73
|
|
@@ -138,11 +142,13 @@ django-solomon provides several settings that you can customize in your Django s
|
|
138
142
|
| `SOLOMON_LOGIN_REDIRECT_URL` | `settings.LOGIN_REDIRECT_URL` | The URL to redirect to after successful authentication |
|
139
143
|
| `SOLOMON_ALLOW_ADMIN_LOGIN` | `True` | If enabled, allows superusers to log in using magic links |
|
140
144
|
| `SOLOMON_ALLOW_STAFF_LOGIN` | `True` | If enabled, allows staff users to log in using magic links |
|
141
|
-
| `SOLOMON_MAIL_TEXT_TEMPLATE`
|
142
|
-
| `SOLOMON_MAIL_MJML_TEMPLATE`
|
145
|
+
| `SOLOMON_MAIL_TEXT_TEMPLATE` | `"django_solomon/email/magic_link.txt"` | The template to use for plain text magic link emails |
|
146
|
+
| `SOLOMON_MAIL_MJML_TEMPLATE` | `"django_solomon/email/magic_link.mjml"` | The template to use for HTML magic link emails (MJML format) |
|
143
147
|
| `SOLOMON_LOGIN_FORM_TEMPLATE` | `"django_solomon/base/login_form.html"` | The template to use for the login form page |
|
144
148
|
| `SOLOMON_INVALID_MAGIC_LINK_TEMPLATE` | `"django_solomon/base/invalid_magic_link.html"` | The template to use for the invalid magic link page |
|
145
149
|
| `SOLOMON_MAGIC_LINK_SENT_TEMPLATE` | `"django_solomon/base/magic_link_sent.html"` | The template to use for the magic link sent confirmation page |
|
150
|
+
| `SOLOMON_ENFORCE_SAME_IP` | `False` | If enabled, validates that magic links are used from the same IP they were created from |
|
151
|
+
| `SOLOMON_ANONYMIZE_IP` | `True` | If enabled, anonymizes IP addresses before storing them (removes last octet for IPv4) |
|
146
152
|
|
147
153
|
## Usage
|
148
154
|
|
@@ -179,19 +185,30 @@ You can also use django-solomon programmatically in your views:
|
|
179
185
|
```python
|
180
186
|
from django.contrib.auth import authenticate, login
|
181
187
|
from django_solomon.models import MagicLink
|
188
|
+
from django_solomon.utilities import get_client_ip
|
182
189
|
|
183
190
|
# Create a magic link for a user
|
184
191
|
magic_link = MagicLink.objects.create_for_user(user)
|
185
192
|
|
193
|
+
# Create a magic link with IP address tracking
|
194
|
+
ip_address = get_client_ip(request)
|
195
|
+
magic_link = MagicLink.objects.create_for_user(user, ip_address=ip_address)
|
196
|
+
|
186
197
|
# Authenticate a user with a token
|
187
198
|
user = authenticate(request=request, token=token)
|
188
199
|
if user:
|
189
200
|
login(request, user)
|
190
201
|
```
|
191
202
|
|
203
|
+
## Documentation
|
204
|
+
|
205
|
+
For more detailed information, tutorials, and advanced usage examples, please visit
|
206
|
+
the [official documentation](https://django-solomon.rtfd.io/).
|
207
|
+
|
192
208
|
## License
|
193
209
|
|
194
|
-
This software is licensed
|
210
|
+
This software is licensed
|
211
|
+
under [MIT license](https://codeberg.org/oliverandrich/django-solomon/src/branch/main/LICENSE).
|
195
212
|
|
196
213
|
## Contributing
|
197
214
|
|
@@ -4,6 +4,8 @@
|
|
4
4
|
[](https://pypi.org/project/django-solomon/)
|
5
5
|
[](https://pypi.org/project/django-solomon/)
|
6
6
|
[](https://django-solomon.rtfd.io/en/latest/?badge=latest)
|
7
|
+
[](https://github.com/astral-sh/ruff)
|
8
|
+
[](https://github.com/astral-sh/uv)
|
7
9
|
|
8
10
|
A Django app for passwordless authentication using magic links.
|
9
11
|
|
@@ -13,6 +15,8 @@ A Django app for passwordless authentication using magic links.
|
|
13
15
|
- Configurable link expiration time
|
14
16
|
- Blacklist functionality to block specific email addresses
|
15
17
|
- Support for auto-creating users when they request a magic link
|
18
|
+
- IP address tracking and validation for enhanced security
|
19
|
+
- Privacy-focused IP anonymization
|
16
20
|
- Customizable templates for emails and pages
|
17
21
|
- Compatible with Django's authentication system
|
18
22
|
|
@@ -87,11 +91,13 @@ django-solomon provides several settings that you can customize in your Django s
|
|
87
91
|
| `SOLOMON_LOGIN_REDIRECT_URL` | `settings.LOGIN_REDIRECT_URL` | The URL to redirect to after successful authentication |
|
88
92
|
| `SOLOMON_ALLOW_ADMIN_LOGIN` | `True` | If enabled, allows superusers to log in using magic links |
|
89
93
|
| `SOLOMON_ALLOW_STAFF_LOGIN` | `True` | If enabled, allows staff users to log in using magic links |
|
90
|
-
| `SOLOMON_MAIL_TEXT_TEMPLATE`
|
91
|
-
| `SOLOMON_MAIL_MJML_TEMPLATE`
|
94
|
+
| `SOLOMON_MAIL_TEXT_TEMPLATE` | `"django_solomon/email/magic_link.txt"` | The template to use for plain text magic link emails |
|
95
|
+
| `SOLOMON_MAIL_MJML_TEMPLATE` | `"django_solomon/email/magic_link.mjml"` | The template to use for HTML magic link emails (MJML format) |
|
92
96
|
| `SOLOMON_LOGIN_FORM_TEMPLATE` | `"django_solomon/base/login_form.html"` | The template to use for the login form page |
|
93
97
|
| `SOLOMON_INVALID_MAGIC_LINK_TEMPLATE` | `"django_solomon/base/invalid_magic_link.html"` | The template to use for the invalid magic link page |
|
94
98
|
| `SOLOMON_MAGIC_LINK_SENT_TEMPLATE` | `"django_solomon/base/magic_link_sent.html"` | The template to use for the magic link sent confirmation page |
|
99
|
+
| `SOLOMON_ENFORCE_SAME_IP` | `False` | If enabled, validates that magic links are used from the same IP they were created from |
|
100
|
+
| `SOLOMON_ANONYMIZE_IP` | `True` | If enabled, anonymizes IP addresses before storing them (removes last octet for IPv4) |
|
95
101
|
|
96
102
|
## Usage
|
97
103
|
|
@@ -128,19 +134,30 @@ You can also use django-solomon programmatically in your views:
|
|
128
134
|
```python
|
129
135
|
from django.contrib.auth import authenticate, login
|
130
136
|
from django_solomon.models import MagicLink
|
137
|
+
from django_solomon.utilities import get_client_ip
|
131
138
|
|
132
139
|
# Create a magic link for a user
|
133
140
|
magic_link = MagicLink.objects.create_for_user(user)
|
134
141
|
|
142
|
+
# Create a magic link with IP address tracking
|
143
|
+
ip_address = get_client_ip(request)
|
144
|
+
magic_link = MagicLink.objects.create_for_user(user, ip_address=ip_address)
|
145
|
+
|
135
146
|
# Authenticate a user with a token
|
136
147
|
user = authenticate(request=request, token=token)
|
137
148
|
if user:
|
138
149
|
login(request, user)
|
139
150
|
```
|
140
151
|
|
152
|
+
## Documentation
|
153
|
+
|
154
|
+
For more detailed information, tutorials, and advanced usage examples, please visit
|
155
|
+
the [official documentation](https://django-solomon.rtfd.io/).
|
156
|
+
|
141
157
|
## License
|
142
158
|
|
143
|
-
This software is licensed
|
159
|
+
This software is licensed
|
160
|
+
under [MIT license](https://codeberg.org/oliverandrich/django-solomon/src/branch/main/LICENSE).
|
144
161
|
|
145
162
|
## Contributing
|
146
163
|
|
@@ -0,0 +1,138 @@
|
|
1
|
+
---
|
2
|
+
hide:
|
3
|
+
- navigation
|
4
|
+
---
|
5
|
+
|
6
|
+
# Contributing to django-solomon
|
7
|
+
|
8
|
+
Thank you for your interest in contributing to django-solomon! This guide will help you get started with the development process.
|
9
|
+
|
10
|
+
## Development Environment Setup
|
11
|
+
|
12
|
+
### Prerequisites
|
13
|
+
|
14
|
+
Before setting up the development environment, ensure you have:
|
15
|
+
|
16
|
+
- Python 3.10 or higher
|
17
|
+
- Git
|
18
|
+
- [uv](https://github.com/astral-sh/uv) for dependency management
|
19
|
+
- [just](https://github.com/casey/just) for running commands
|
20
|
+
|
21
|
+
### Setting Up the Development Environment
|
22
|
+
|
23
|
+
1. Clone the repository:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
git clone https://codeberg.org/oliverandrich/django-solomon.git
|
27
|
+
cd django-solomon
|
28
|
+
```
|
29
|
+
|
30
|
+
2. Set up the development environment using the bootstrap command:
|
31
|
+
|
32
|
+
```bash
|
33
|
+
just bootstrap
|
34
|
+
```
|
35
|
+
|
36
|
+
This command will:
|
37
|
+
- Initialize a git repository
|
38
|
+
- Install all dependencies
|
39
|
+
- Set up pre-commit hooks
|
40
|
+
|
41
|
+
If you already have a cloned repository, you can install dependencies with:
|
42
|
+
|
43
|
+
```bash
|
44
|
+
just upgrade
|
45
|
+
```
|
46
|
+
|
47
|
+
## Development Workflow
|
48
|
+
|
49
|
+
### Running Tests
|
50
|
+
|
51
|
+
To run the test suite with coverage reporting:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
just test
|
55
|
+
```
|
56
|
+
|
57
|
+
To run the full test suite across all supported Python and Django versions:
|
58
|
+
|
59
|
+
```bash
|
60
|
+
just test-all
|
61
|
+
```
|
62
|
+
|
63
|
+
### Linting and Code Quality
|
64
|
+
|
65
|
+
The project uses Ruff for linting and formatting. To run the linters:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
just lint
|
69
|
+
```
|
70
|
+
|
71
|
+
This will run all pre-commit hooks, including Ruff linting and formatting.
|
72
|
+
|
73
|
+
### Documentation
|
74
|
+
|
75
|
+
To serve the documentation locally:
|
76
|
+
|
77
|
+
```bash
|
78
|
+
just serve-docs
|
79
|
+
```
|
80
|
+
|
81
|
+
This will start a local server at http://127.0.0.1:8000/ where you can preview the documentation.
|
82
|
+
|
83
|
+
## Coding Standards
|
84
|
+
|
85
|
+
### Python Style Guide
|
86
|
+
|
87
|
+
The project follows the PEP 8 style guide with some modifications:
|
88
|
+
|
89
|
+
- Maximum line length is 120 characters
|
90
|
+
- Uses double quotes for strings
|
91
|
+
- Does NOT use relative imports for internal modules
|
92
|
+
|
93
|
+
Ruff is configured to enforce these standards. The configuration can be found in `pyproject.toml`.
|
94
|
+
|
95
|
+
### Type Annotations
|
96
|
+
|
97
|
+
The project uses type annotations and mypy for type checking. Please add type annotations to all new code.
|
98
|
+
|
99
|
+
### Testing
|
100
|
+
|
101
|
+
All new features and bug fixes should include tests. The project uses pytest for testing.
|
102
|
+
|
103
|
+
- Place tests in the `tests/` directory
|
104
|
+
- Ensure tests are isolated and don't depend on external services
|
105
|
+
- Aim for high test coverage
|
106
|
+
|
107
|
+
## Pull Request Process
|
108
|
+
|
109
|
+
1. Fork the repository on [Codeberg](https://codeberg.org/oliverandrich/django-solomon)
|
110
|
+
2. Create a new branch for your feature or bug fix
|
111
|
+
3. Make your changes, following the coding standards
|
112
|
+
4. Add tests for your changes
|
113
|
+
5. Run the test suite to ensure all tests pass
|
114
|
+
6. Update the documentation if necessary
|
115
|
+
7. Submit a pull request to the main repository
|
116
|
+
|
117
|
+
### Pull Request Guidelines
|
118
|
+
|
119
|
+
- Keep pull requests focused on a single feature or bug fix
|
120
|
+
- Include a clear description of the changes
|
121
|
+
- Reference any related issues
|
122
|
+
- Ensure all tests pass and code quality checks succeed
|
123
|
+
- Update the CHANGELOG.md file if your changes are user-facing
|
124
|
+
|
125
|
+
## Release Process
|
126
|
+
|
127
|
+
The project follows [Semantic Versioning](https://semver.org/). The release process is handled by the maintainers.
|
128
|
+
|
129
|
+
## Getting Help
|
130
|
+
|
131
|
+
If you have questions or need help with the development process, you can:
|
132
|
+
|
133
|
+
- Open an issue on [Codeberg](https://codeberg.org/oliverandrich/django-solomon/issues)
|
134
|
+
- Contact the maintainers directly
|
135
|
+
|
136
|
+
## Code of Conduct
|
137
|
+
|
138
|
+
Please be respectful and considerate of others when contributing to the project. We aim to foster an inclusive and welcoming community.
|
@@ -0,0 +1,174 @@
|
|
1
|
+
---
|
2
|
+
hide:
|
3
|
+
- navigation
|
4
|
+
---
|
5
|
+
|
6
|
+
# Installation and Setup
|
7
|
+
|
8
|
+
This guide will walk you through the process of installing and setting up django-solomon in your Django project.
|
9
|
+
|
10
|
+
## Prerequisites
|
11
|
+
|
12
|
+
Before installing django-solomon, ensure you have:
|
13
|
+
|
14
|
+
- Python 3.10 or higher
|
15
|
+
- Django 4.2 or higher
|
16
|
+
- A working email configuration for sending magic links
|
17
|
+
|
18
|
+
## Installation Methods
|
19
|
+
|
20
|
+
### Using pip (Recommended)
|
21
|
+
|
22
|
+
The simplest way to install django-solomon is using pip:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
pip install django-solomon
|
26
|
+
```
|
27
|
+
|
28
|
+
### Using a Virtual Environment
|
29
|
+
|
30
|
+
It's recommended to install django-solomon in a virtual environment:
|
31
|
+
|
32
|
+
```bash
|
33
|
+
# Create a virtual environment
|
34
|
+
python -m venv venv
|
35
|
+
|
36
|
+
# Activate the virtual environment
|
37
|
+
# On Windows
|
38
|
+
venv\Scripts\activate
|
39
|
+
# On macOS/Linux
|
40
|
+
source venv/bin/activate
|
41
|
+
|
42
|
+
# Install django-solomon
|
43
|
+
pip install django-solomon
|
44
|
+
```
|
45
|
+
|
46
|
+
### From Source
|
47
|
+
|
48
|
+
You can also install django-solomon directly from the source code:
|
49
|
+
|
50
|
+
```bash
|
51
|
+
git clone https://codeberg.org/oliverandrich/django-solomon.git
|
52
|
+
cd django-solomon
|
53
|
+
pip install -e .
|
54
|
+
```
|
55
|
+
|
56
|
+
## Configuration Steps
|
57
|
+
|
58
|
+
After installing django-solomon, you need to configure your Django project to use it:
|
59
|
+
|
60
|
+
### 1. Add to INSTALLED_APPS
|
61
|
+
|
62
|
+
Add `django_solomon` to your `INSTALLED_APPS` in your Django settings:
|
63
|
+
|
64
|
+
```python
|
65
|
+
INSTALLED_APPS = [
|
66
|
+
# ...
|
67
|
+
'django_solomon',
|
68
|
+
# ...
|
69
|
+
]
|
70
|
+
```
|
71
|
+
|
72
|
+
### 2. Configure Authentication Backend
|
73
|
+
|
74
|
+
Add the authentication backend to your settings:
|
75
|
+
|
76
|
+
```python
|
77
|
+
AUTHENTICATION_BACKENDS = [
|
78
|
+
'django_solomon.backends.MagicLinkBackend',
|
79
|
+
'django.contrib.auth.backends.ModelBackend', # Keep the default backend
|
80
|
+
]
|
81
|
+
```
|
82
|
+
|
83
|
+
### 3. Include URLs
|
84
|
+
|
85
|
+
Include the django-solomon URLs in your project's `urls.py`:
|
86
|
+
|
87
|
+
```python
|
88
|
+
from django.urls import include, path
|
89
|
+
|
90
|
+
urlpatterns = [
|
91
|
+
# ...
|
92
|
+
path('auth/', include('django_solomon.urls')),
|
93
|
+
# ...
|
94
|
+
]
|
95
|
+
```
|
96
|
+
|
97
|
+
### 4. Set Login URL
|
98
|
+
|
99
|
+
Set the login URL in your settings to use django-solomon's login view:
|
100
|
+
|
101
|
+
```python
|
102
|
+
LOGIN_URL = 'django_solomon:login'
|
103
|
+
```
|
104
|
+
|
105
|
+
This ensures that when users need to authenticate, they'll be redirected to the magic link login page.
|
106
|
+
|
107
|
+
### 5. Configure Email Settings
|
108
|
+
|
109
|
+
Configure your email settings to ensure magic link emails can be sent:
|
110
|
+
|
111
|
+
```python
|
112
|
+
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
113
|
+
EMAIL_HOST = 'smtp.example.com'
|
114
|
+
EMAIL_PORT = 587
|
115
|
+
EMAIL_USE_TLS = True
|
116
|
+
EMAIL_HOST_USER = 'your-email@example.com'
|
117
|
+
EMAIL_HOST_PASSWORD = 'your-password'
|
118
|
+
DEFAULT_FROM_EMAIL = 'your-email@example.com'
|
119
|
+
```
|
120
|
+
|
121
|
+
For development, you can use Django's console email backend to display emails in the console:
|
122
|
+
|
123
|
+
```python
|
124
|
+
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
125
|
+
```
|
126
|
+
|
127
|
+
## Customizing Settings
|
128
|
+
|
129
|
+
django-solomon provides several settings that you can customize in your Django settings file. For a comprehensive list of all available settings and their detailed descriptions, please refer to the [Settings documentation](settings.md).
|
130
|
+
|
131
|
+
## Verifying Installation
|
132
|
+
|
133
|
+
To verify that django-solomon is correctly installed and configured:
|
134
|
+
|
135
|
+
1. Start your Django development server:
|
136
|
+
```bash
|
137
|
+
python manage.py runserver
|
138
|
+
```
|
139
|
+
|
140
|
+
2. Navigate to the login URL (e.g., `http://localhost:8000/auth/magic-link/`)
|
141
|
+
|
142
|
+
3. Enter an email address and request a magic link
|
143
|
+
|
144
|
+
4. Check that the magic link is sent (in the console if using the console email backend)
|
145
|
+
|
146
|
+
5. Click the magic link to authenticate
|
147
|
+
|
148
|
+
## Troubleshooting
|
149
|
+
|
150
|
+
### Magic Links Not Being Sent
|
151
|
+
|
152
|
+
- Check your email configuration settings
|
153
|
+
- Ensure your SMTP server is accessible
|
154
|
+
- Try using the console email backend for testing
|
155
|
+
|
156
|
+
### Authentication Not Working
|
157
|
+
|
158
|
+
- Verify that the MagicLinkBackend is in your AUTHENTICATION_BACKENDS
|
159
|
+
- Check that the URLs are correctly included in your urls.py
|
160
|
+
- Ensure the magic link hasn't expired or been used already
|
161
|
+
|
162
|
+
### Template Errors
|
163
|
+
|
164
|
+
- Make sure django_solomon is in your INSTALLED_APPS
|
165
|
+
- Check that you're not overriding templates incorrectly
|
166
|
+
- Verify that your custom templates extend the correct base templates
|
167
|
+
|
168
|
+
## Next Steps
|
169
|
+
|
170
|
+
Now that you have django-solomon installed and configured, you can:
|
171
|
+
|
172
|
+
- Customize the templates to match your site's design
|
173
|
+
- Integrate the magic link login with your existing authentication flow
|
174
|
+
- Explore the programmatic API for advanced usage
|