Add scoped redirects, database logins and SFTP folder access
This commit is contained in:
1 parent
0263aa4bfa
commit
4b60663821
50 files changed
+2640
-57
No files matched your search
@@ -14,6 +14,7 @@ from django.utils import timezone
|
||||
from coulobre.account_backup_request import backup_archive
|
||||
from coulobre.account_backup_retention import MAX_RETAINED_BACKUPS
|
||||
from coulobre.account_restore_request import MAX_RESTORE_PATH_BYTES
|
||||
from coulobre.database_login import DatabaseLoginSpec
|
||||
from coulobre.database_node import (
|
||||
DATABASE_SUFFIX_PATTERN,
|
||||
INVALID_SUFFIX,
|
||||
@@ -594,6 +595,12 @@ class ServiceSignOnGrant(models.Model):
|
||||
|
||||
class PhpMyAdminGrant(ServiceSignOnGrant):
|
||||
database = models.ForeignKey(HostingDatabase, on_delete=models.CASCADE)
|
||||
database_login = models.ForeignKey(
|
||||
"DatabaseLogin",
|
||||
null=True,
|
||||
blank=True,
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
|
||||
|
||||
class RoundcubeGrant(ServiceSignOnGrant):
|
||||
@@ -828,6 +835,57 @@ class ProvisioningJob(models.Model):
|
||||
return "running" if self.started_at else "queued"
|
||||
|
||||
|
||||
class FolderSftpLogin(ProvisioningJob):
|
||||
account = models.ForeignKey(
|
||||
HostingAccount,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="folder_sftp_logins",
|
||||
)
|
||||
domain = DomainNameField(max_length=253)
|
||||
label = models.CharField(max_length=80)
|
||||
folder = models.CharField(max_length=1024, blank=True)
|
||||
public_keys = models.TextField()
|
||||
action = models.CharField(max_length=6, default="create")
|
||||
requested_customer_id = models.PositiveBigIntegerField()
|
||||
|
||||
@property
|
||||
def spec(self):
|
||||
from coulobre.folder_sftp import FolderSftpRequest
|
||||
|
||||
return FolderSftpRequest(
|
||||
WebSite(self.account_id, self.domain),
|
||||
self.pk,
|
||||
self.folder,
|
||||
self.action,
|
||||
self.public_keys if self.action != "remove" else "",
|
||||
)
|
||||
|
||||
|
||||
class DatabaseLogin(ProvisioningJob):
|
||||
class Access(models.TextChoices):
|
||||
READ = "read", "Read only"
|
||||
WRITE = "write", "Read and write"
|
||||
|
||||
database = models.ForeignKey(
|
||||
HostingDatabase,
|
||||
related_name="logins",
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
label = models.CharField(max_length=80)
|
||||
access = models.CharField(
|
||||
max_length=6, choices=Access, default=Access.READ
|
||||
)
|
||||
action = models.CharField(max_length=6, default="grant")
|
||||
requested_customer_id = models.PositiveBigIntegerField()
|
||||
|
||||
def __str__(self):
|
||||
return self.spec.name
|
||||
|
||||
@property
|
||||
def spec(self):
|
||||
return DatabaseLoginSpec(self.database.spec, self.pk)
|
||||
|
||||
|
||||
class OperatorOperation(ProvisioningJob):
|
||||
actor = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True
|
||||
@@ -1037,6 +1095,27 @@ class WebsiteCertificateJob(ProvisioningJob):
|
||||
certificate = models.JSONField(default=dict)
|
||||
|
||||
|
||||
class WebsiteRedirectPolicy(ProvisioningJob):
|
||||
account = models.ForeignKey(
|
||||
HostingAccount,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="redirect_policies",
|
||||
)
|
||||
domain = DomainNameField(max_length=253)
|
||||
website = models.JSONField()
|
||||
requested_rules = models.JSONField(default=list)
|
||||
applied_rules = models.JSONField(default=list)
|
||||
requested_customer_id = models.PositiveBigIntegerField(null=True)
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["account", "domain"],
|
||||
name="website_redirect_per_domain",
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class WebsiteAlias(ProvisioningJob):
|
||||
wait_for_website = models.BooleanField(default=False)
|
||||
|
||||
@@ -1166,6 +1245,9 @@ class AccountBackupJob(ProvisioningJob):
|
||||
manifest = models.JSONField()
|
||||
remote_mail = models.BooleanField(default=False)
|
||||
export_customer_id = models.PositiveBigIntegerField(null=True, blank=True)
|
||||
export_database_suffix = models.CharField(
|
||||
max_length=24, blank=True, default=""
|
||||
)
|
||||
scheduled_for = models.DateTimeField(null=True, blank=True)
|
||||
archive_bytes = models.PositiveBigIntegerField(null=True, blank=True)
|
||||
retention_protected = models.BooleanField(default=False)
|
||||
|
||||
Reference in new issue
Block a user