django-solomon 0.3.0__py3-none-any.whl → 0.4.1__py3-none-any.whl
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/apps.py +20 -0
- django_solomon/migrations/0003_add_unique_constraint_auth_user_email.py +43 -0
- {django_solomon-0.3.0.dist-info → django_solomon-0.4.1.dist-info}/METADATA +17 -14
- {django_solomon-0.3.0.dist-info → django_solomon-0.4.1.dist-info}/RECORD +6 -5
- {django_solomon-0.3.0.dist-info → django_solomon-0.4.1.dist-info}/WHEEL +0 -0
- {django_solomon-0.3.0.dist-info → django_solomon-0.4.1.dist-info}/licenses/LICENSE +0 -0
django_solomon/apps.py
CHANGED
@@ -4,3 +4,23 @@ from django.apps import AppConfig
|
|
4
4
|
class DjangoSolomonConfig(AppConfig):
|
5
5
|
default_auto_field = "django.db.models.BigAutoField"
|
6
6
|
name = "django_solomon"
|
7
|
+
|
8
|
+
def ready(self):
|
9
|
+
from django.contrib.auth.models import User
|
10
|
+
from django.db import models
|
11
|
+
|
12
|
+
# Updating the field itself triggers the auto-detector
|
13
|
+
# field = User._meta.get_field("email")
|
14
|
+
# field._unique = True
|
15
|
+
#
|
16
|
+
# But setting a constraint does not...
|
17
|
+
User.Meta.constraints = [
|
18
|
+
models.UniqueConstraint(
|
19
|
+
name="unique_user_email",
|
20
|
+
fields=["email"],
|
21
|
+
# deferrable=models.Deferrable.DEFERRED,
|
22
|
+
),
|
23
|
+
]
|
24
|
+
User._meta.constraints = User.Meta.constraints
|
25
|
+
# ... as long as original_attrs is not updated.
|
26
|
+
User._meta.original_attrs["constraints"] = User.Meta.constraints
|
@@ -0,0 +1,43 @@
|
|
1
|
+
from django.db import migrations, models
|
2
|
+
from django.db.models.functions import Lower
|
3
|
+
|
4
|
+
|
5
|
+
# Copyright (c) 2023 Carlton Gibson
|
6
|
+
# This migration is taken from the fantastic project `django-unique-user-email` created by Carlton Gibson.
|
7
|
+
# https://github.com/carltongibson/django-unique-user-email/
|
8
|
+
|
9
|
+
|
10
|
+
class CustomAddConstraint(migrations.AddConstraint):
|
11
|
+
"""
|
12
|
+
Override app_label to target auth.User
|
13
|
+
"""
|
14
|
+
|
15
|
+
def state_forwards(self, app_label, state):
|
16
|
+
state.add_constraint("auth", self.model_name_lower, self.constraint)
|
17
|
+
|
18
|
+
def database_forwards(self, app_label, schema_editor, from_state, to_state):
|
19
|
+
model = to_state.apps.get_model("auth", self.model_name)
|
20
|
+
if self.allow_migrate_model(schema_editor.connection.alias, model):
|
21
|
+
schema_editor.add_constraint(model, self.constraint)
|
22
|
+
|
23
|
+
def database_backwards(self, app_label, schema_editor, from_state, to_state):
|
24
|
+
model = to_state.apps.get_model("auth", self.model_name)
|
25
|
+
if self.allow_migrate_model(schema_editor.connection.alias, model):
|
26
|
+
schema_editor.remove_constraint(model, self.constraint)
|
27
|
+
|
28
|
+
|
29
|
+
class Migration(migrations.Migration):
|
30
|
+
dependencies = [
|
31
|
+
("django_solomon", "0002_magiclink_ip_address"),
|
32
|
+
("auth", "0012_alter_user_first_name_max_length"),
|
33
|
+
]
|
34
|
+
|
35
|
+
operations = [
|
36
|
+
CustomAddConstraint(
|
37
|
+
model_name="user",
|
38
|
+
constraint=models.UniqueConstraint(
|
39
|
+
Lower("email"),
|
40
|
+
name="unique_user_email"
|
41
|
+
),
|
42
|
+
),
|
43
|
+
]
|
@@ -1,10 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: django-solomon
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.1
|
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/
|
7
7
|
Project-URL: Repository, https://codeberg.org/oliverandrich/django-solomon
|
8
|
+
Project-URL: Issue Tracker, https://codeberg.org/oliverandrich/django-solomon/issues
|
8
9
|
Author-email: Oliver Andrich <oliver@andrich.me>
|
9
10
|
License: MIT License
|
10
11
|
|
@@ -52,6 +53,7 @@ Description-Content-Type: text/markdown
|
|
52
53
|
# django-solomon
|
53
54
|
|
54
55
|
[](https://pypi.org/project/django-solomon/)
|
56
|
+

|
55
57
|
[](https://pypi.org/project/django-solomon/)
|
56
58
|
[](https://pypi.org/project/django-solomon/)
|
57
59
|
[](https://django-solomon.rtfd.io/en/latest/?badge=latest)
|
@@ -70,6 +72,7 @@ A Django app for passwordless authentication using magic links.
|
|
70
72
|
- Privacy-focused IP anonymization
|
71
73
|
- Customizable templates for emails and pages
|
72
74
|
- Compatible with Django's authentication system
|
75
|
+
- Enforces unique email addresses for users (case-insensitive)
|
73
76
|
|
74
77
|
## Installation
|
75
78
|
|
@@ -134,19 +137,19 @@ DEFAULT_FROM_EMAIL = 'your-email@example.com'
|
|
134
137
|
|
135
138
|
django-solomon provides several settings that you can customize in your Django settings file:
|
136
139
|
|
137
|
-
| Setting | Default | Description
|
138
|
-
|
139
|
-
| `SOLOMON_LINK_EXPIRATION` | `300` | The expiration time for magic links in seconds
|
140
|
-
| `SOLOMON_ONLY_ONE_LINK_ALLOWED` | `True` | If enabled, only one active magic link is allowed per user
|
141
|
-
| `SOLOMON_CREATE_USER_IF_NOT_FOUND` | `False` | If enabled, creates a new user when a magic link is requested for a non-existent email
|
142
|
-
| `SOLOMON_LOGIN_REDIRECT_URL` | `settings.LOGIN_REDIRECT_URL` | The URL to redirect to after successful authentication
|
143
|
-
| `SOLOMON_ALLOW_ADMIN_LOGIN` | `True` | If enabled, allows superusers to log in using magic links
|
144
|
-
| `SOLOMON_ALLOW_STAFF_LOGIN` | `True` | If enabled, allows staff users to log in using magic links
|
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)
|
147
|
-
| `SOLOMON_LOGIN_FORM_TEMPLATE` | `"django_solomon/base/login_form.html"` | The template to use for the login form page
|
148
|
-
| `SOLOMON_INVALID_MAGIC_LINK_TEMPLATE` | `"django_solomon/base/invalid_magic_link.html"` | The template to use for the invalid magic link page
|
149
|
-
| `SOLOMON_MAGIC_LINK_SENT_TEMPLATE` | `"django_solomon/base/magic_link_sent.html"` | The template to use for the magic link sent confirmation page
|
140
|
+
| Setting | Default | Description |
|
141
|
+
|---------------------------------------|-------------------------------------------------|-----------------------------------------------------------------------------------------|
|
142
|
+
| `SOLOMON_LINK_EXPIRATION` | `300` | The expiration time for magic links in seconds |
|
143
|
+
| `SOLOMON_ONLY_ONE_LINK_ALLOWED` | `True` | If enabled, only one active magic link is allowed per user |
|
144
|
+
| `SOLOMON_CREATE_USER_IF_NOT_FOUND` | `False` | If enabled, creates a new user when a magic link is requested for a non-existent email |
|
145
|
+
| `SOLOMON_LOGIN_REDIRECT_URL` | `settings.LOGIN_REDIRECT_URL` | The URL to redirect to after successful authentication |
|
146
|
+
| `SOLOMON_ALLOW_ADMIN_LOGIN` | `True` | If enabled, allows superusers to log in using magic links |
|
147
|
+
| `SOLOMON_ALLOW_STAFF_LOGIN` | `True` | If enabled, allows staff users to log in using magic links |
|
148
|
+
| `SOLOMON_MAIL_TEXT_TEMPLATE` | `"django_solomon/email/magic_link.txt"` | The template to use for plain text magic link emails |
|
149
|
+
| `SOLOMON_MAIL_MJML_TEMPLATE` | `"django_solomon/email/magic_link.mjml"` | The template to use for HTML magic link emails (MJML format) |
|
150
|
+
| `SOLOMON_LOGIN_FORM_TEMPLATE` | `"django_solomon/base/login_form.html"` | The template to use for the login form page |
|
151
|
+
| `SOLOMON_INVALID_MAGIC_LINK_TEMPLATE` | `"django_solomon/base/invalid_magic_link.html"` | The template to use for the invalid magic link page |
|
152
|
+
| `SOLOMON_MAGIC_LINK_SENT_TEMPLATE` | `"django_solomon/base/magic_link_sent.html"` | The template to use for the magic link sent confirmation page |
|
150
153
|
| `SOLOMON_ENFORCE_SAME_IP` | `False` | If enabled, validates that magic links are used from the same IP they were created from |
|
151
154
|
| `SOLOMON_ANONYMIZE_IP` | `True` | If enabled, anonymizes IP addresses before storing them (removes last octet for IPv4) |
|
152
155
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
django_solomon/__init__.py,sha256=4GdjeQVyChzdc7pZ1jrpknjcnu9Do_0nSh42UZNICKo,80
|
2
2
|
django_solomon/admin.py,sha256=hwesCOQgUDDHPh5qq97AObfSyMgIOKsdzoa69naMPx4,1428
|
3
|
-
django_solomon/apps.py,sha256=
|
3
|
+
django_solomon/apps.py,sha256=lmhPt8Cgdk-tr-cK45Ysdkqe8rPrTBH_UqYClpKZ94o,883
|
4
4
|
django_solomon/backends.py,sha256=3RN4dsCehg5urp9sfASERFda1VR9nislNvHrxUc7rXM,3171
|
5
5
|
django_solomon/config.py,sha256=JEl3cY0BnfC9ja0ZVeLmfIwUStbUAO6vRhGZrrig5Yw,787
|
6
6
|
django_solomon/forms.py,sha256=ymDsZ-KWyJfo12vGbZCxIhIvVket93xYR4MgDif4fh0,312
|
@@ -15,13 +15,14 @@ django_solomon/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
15
15
|
django_solomon/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
16
|
django_solomon/migrations/0001_initial.py,sha256=i-UhR1KQ4p7WmbDg9xUQfMmDo8yYdIigvHNsefLHJEc,1981
|
17
17
|
django_solomon/migrations/0002_magiclink_ip_address.py,sha256=hs3MISYV7IHEqF-vELCmFtzhhvK8GEHkZu8RMc4X1YU,432
|
18
|
+
django_solomon/migrations/0003_add_unique_constraint_auth_user_email.py,sha256=9-etXYGGm72G5bmeSdQNpxfQsVl2fTPLyt2sP-CK0G0,1529
|
18
19
|
django_solomon/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
20
|
django_solomon/templates/django_solomon/base/invalid_magic_link.html,sha256=3U4T2n4uvPvktiOOHYVyNmk0aXFfE4DPrURE1DinWKk,554
|
20
21
|
django_solomon/templates/django_solomon/base/login_form.html,sha256=VYGnrno3c36W9f04XdRqJpjsDfOy0sq5D_cLayPz8Q0,546
|
21
22
|
django_solomon/templates/django_solomon/base/magic_link_sent.html,sha256=GIMxnw3E98TXVkVQkMRTHmX5mz0xUsvgXVj25gO2HPQ,461
|
22
23
|
django_solomon/templates/django_solomon/email/magic_link.mjml,sha256=OnfVGm2yFrOmoQ1syo6-Duq_Qraf3Tv0Vy5oidvt55g,1427
|
23
24
|
django_solomon/templates/django_solomon/email/magic_link.txt,sha256=yl01eie3U2HkFEJvB1Qlm8Z6FPuop5yubDXFY5V507Q,502
|
24
|
-
django_solomon-0.
|
25
|
-
django_solomon-0.
|
26
|
-
django_solomon-0.
|
27
|
-
django_solomon-0.
|
25
|
+
django_solomon-0.4.1.dist-info/METADATA,sha256=a0NZFRUcRHdLooXHNdgye55MofE_8zbcLHkkJC_l5vk,10409
|
26
|
+
django_solomon-0.4.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
django_solomon-0.4.1.dist-info/licenses/LICENSE,sha256=tbfFOFdH5mHIfmNGo6KGOC3U8f-hTCLfetcr8A89WwI,1071
|
28
|
+
django_solomon-0.4.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|