Manage mailbox passwords and quotas from the owning panel
This commit is contained in:
1 parent
63b73b4102
commit
9c4288bb08
25 files changed
+541
-58
No files matched your search
@@ -18,11 +18,13 @@ from coulobre.service_credentials import (
|
||||
CREDENTIAL_TIMEOUT_SECONDS,
|
||||
CREDENTIALS_UNAVAILABLE,
|
||||
MAIL_CREDENTIAL_SOCKET,
|
||||
MAIL_PASSWORD_SOCKET,
|
||||
ROTATION_TIMEOUT_SECONDS,
|
||||
ServiceCredentialRequest,
|
||||
)
|
||||
|
||||
from .access import customer_for_user, reseller_for_user
|
||||
from .installation_features import panel_feature_allowed
|
||||
from .models import ServiceCredentialAccess
|
||||
from .node_client import apply_on_local_node
|
||||
from .resource_requests import lock_hosting_account, require_active_services
|
||||
@@ -77,6 +79,8 @@ def enabled_credential_access(request, kind):
|
||||
|
||||
|
||||
def enabled_rotation(request, kind):
|
||||
if kind == CredentialKind.MAILBOX and mailbox_password_changes_enabled():
|
||||
return not settings.DEBUG and request.is_secure()
|
||||
if not enabled_credential_access(request, kind):
|
||||
return False
|
||||
if kind == CredentialKind.DATABASE:
|
||||
@@ -86,6 +90,12 @@ def enabled_rotation(request, kind):
|
||||
return settings.LOCAL_MAILBOX_CREDENTIAL_ROTATION
|
||||
|
||||
|
||||
def mailbox_password_changes_enabled():
|
||||
return panel_feature_allowed(
|
||||
"MAILBOX_PASSWORD_CHANGES"
|
||||
) and panel_feature_allowed("LOCAL_MAILBOX_PROVISIONING")
|
||||
|
||||
|
||||
def can_reveal_credentials(user, kind):
|
||||
if not user.is_authenticated or not user.is_active:
|
||||
return False
|
||||
@@ -111,6 +121,14 @@ def show_credential_action(request, kind):
|
||||
)
|
||||
|
||||
|
||||
def show_rotation_action(request, kind):
|
||||
return (
|
||||
getattr(request, "impersonation", None) is None
|
||||
and enabled_rotation(request, kind)
|
||||
and can_rotate_credentials(request.user, kind)
|
||||
)
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
@sensitive_variables()
|
||||
def verify_credential_access(
|
||||
@@ -156,20 +174,24 @@ def verify_credential_access(
|
||||
|
||||
@sensitive_variables()
|
||||
def send_credential_request(spec):
|
||||
remote = (
|
||||
spec.kind == CredentialKind.MAILBOX
|
||||
and settings.REMOTE_MAILBOX_CREDENTIALS
|
||||
address = CREDENTIAL_SOCKET
|
||||
timeout = (
|
||||
ROTATION_TIMEOUT_SECONDS
|
||||
if spec.operation == "rotate"
|
||||
else CREDENTIAL_TIMEOUT_SECONDS
|
||||
)
|
||||
if spec.kind == CredentialKind.MAILBOX:
|
||||
if spec.operation != "read" and mailbox_password_changes_enabled():
|
||||
address = MAIL_PASSWORD_SOCKET
|
||||
timeout = 50
|
||||
elif settings.REMOTE_MAILBOX_CREDENTIALS:
|
||||
address = MAIL_CREDENTIAL_SOCKET
|
||||
return apply_on_local_node(
|
||||
spec,
|
||||
MAIL_CREDENTIAL_SOCKET if remote else CREDENTIAL_SOCKET,
|
||||
address,
|
||||
"credential node",
|
||||
"service credential request",
|
||||
timeout=(
|
||||
ROTATION_TIMEOUT_SECONDS
|
||||
if spec.operation == "rotate"
|
||||
else CREDENTIAL_TIMEOUT_SECONDS
|
||||
),
|
||||
timeout=timeout,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user