Add self-service account security and session revocation
This commit is contained in:
1 parent
3d1c666f5e
commit
22205f4e4b
15 files changed
+1129
-33
No files matched your search
@@ -1354,3 +1354,40 @@ class PanelRecoveryCode(models.Model):
|
||||
name="hosting_unique_panel_recovery_code",
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class PanelAccountSecurity(models.Model):
|
||||
user = models.OneToOneField(
|
||||
settings.AUTH_USER_MODEL, on_delete=models.CASCADE
|
||||
)
|
||||
session_version = models.PositiveBigIntegerField(default=0)
|
||||
|
||||
|
||||
class PanelEmailChange(models.Model):
|
||||
user = models.OneToOneField(
|
||||
settings.AUTH_USER_MODEL, on_delete=models.CASCADE
|
||||
)
|
||||
email = models.EmailField()
|
||||
digest = models.CharField(max_length=64)
|
||||
session_digest = models.CharField(max_length=64)
|
||||
expires_at = models.DateTimeField()
|
||||
|
||||
|
||||
class PanelSecurityEvent(models.Model):
|
||||
class Action(models.TextChoices):
|
||||
PASSWORD = "password", "Password changed"
|
||||
EMAIL = "email", "Email address changed"
|
||||
FACTOR = "factor", "Authenticator updated"
|
||||
RECOVERY = "recovery", "Recovery codes replaced"
|
||||
RESET = "reset", "Operator-issued factor recovery"
|
||||
SESSIONS = "sessions", "Other sessions signed out"
|
||||
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True
|
||||
)
|
||||
username = models.CharField(max_length=150)
|
||||
action = models.CharField(max_length=12, choices=Action.choices)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
indexes = [models.Index(fields=["user", "-id"])]
|
||||
Reference in new issue
Block a user