Allow scoped and audited writes during customer support
This commit is contained in:
1 parent
6e73e342ab
commit
930b692328
13 files changed
+378
-62
No files matched your search
@@ -137,6 +137,7 @@ class CustomerImpersonation(models.Model):
|
||||
)
|
||||
operator_username = models.CharField(max_length=150)
|
||||
customer_username = models.CharField(max_length=150)
|
||||
write_enabled = models.BooleanField(default=False)
|
||||
started_at = models.DateTimeField(default=timezone.now)
|
||||
expires_at = models.DateTimeField()
|
||||
ended_at = models.DateTimeField(null=True, blank=True)
|
||||
@@ -150,12 +151,39 @@ class CustomerImpersonation(models.Model):
|
||||
verbose_name = "customer impersonation session"
|
||||
permissions = (
|
||||
("impersonate_customer", "Can view the panel as a customer"),
|
||||
(
|
||||
"write_as_customer",
|
||||
"Can start a support session with write access",
|
||||
),
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.operator_username} viewing as {self.customer_username}"
|
||||
|
||||
|
||||
class CustomerImpersonationAction(models.Model):
|
||||
class Operation(models.TextChoices):
|
||||
DATABASE = "database", "Requested database"
|
||||
MAILBOX = "mailbox", "Requested mailbox"
|
||||
ADD_KEYS = "add_keys", "Queued SSH key upload"
|
||||
REMOVE_KEY = "remove_key", "Queued SSH key removal"
|
||||
REVOKE_SFTP = "revoke_sftp", "Queued SFTP revocation"
|
||||
|
||||
session = models.ForeignKey(
|
||||
CustomerImpersonation, on_delete=models.PROTECT, related_name="actions"
|
||||
)
|
||||
hosting_account_id = models.PositiveBigIntegerField()
|
||||
operation = models.CharField(max_length=16, choices=Operation.choices)
|
||||
resource = models.CharField(max_length=254)
|
||||
details = models.JSONField(default=dict)
|
||||
requested_at = models.DateTimeField(default=timezone.now)
|
||||
|
||||
class Meta:
|
||||
ordering = ("-requested_at", "-pk")
|
||||
default_permissions = ("view",)
|
||||
verbose_name = "customer impersonation action"
|
||||
|
||||
|
||||
class ServiceCredentialAccess(models.Model):
|
||||
class Kind(models.TextChoices):
|
||||
DATABASE = "database", "MariaDB database"
|
||||
|
||||
Reference in new issue
Block a user