mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-06 15:12:30 +09:00
An owner/admin can share a specific application (transitively its WordPress site / DB / domains) with a specific user who doesn't own it. Access-level for now; per-grant view/edit roles are reserved via a role column. - New ResourceGrant model (Alembic 016, unique per user x resource) + ResourceGrantService (grant/revoke/list/user_has_grant/granted_ids). - Enforcement at the cleanest seams: scope_query gained grant_resource_type so granted apps appear in the apps list (own OR granted, then workspace-narrowed); get_app and the WordPress _owner_or_admin_app helper became grant-aware, so one change opens every WP per-site route to a grantee. - Grant-management API (GET/POST/DELETE /apps/<id>/grants, owner-or-admin; can't grant to the owner; revoke is resource-scoped so you can't revoke another app's grant by id). Uses user.id (int), not the stringified get_jwt_identity(). Verified: 4 new ACL tests (visibility, get_app, WP route access, management perms + idempotency + revoke), full suite 127 passed, end-to-end alembic upgrade to 016. Deferred: a Sharing UI (next), and broadening grant-access to the generic app operate endpoints (start/stop/update stay owner-or-admin; delete stays owner-only). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
60 lines
3.7 KiB
Python
60 lines
3.7 KiB
Python
from app.models.user import User
|
|
from app.models.application import Application
|
|
from app.models.domain import Domain
|
|
from app.models.env_variable import EnvironmentVariable, EnvironmentVariableHistory
|
|
from app.models.notification_preferences import NotificationPreferences
|
|
from app.models.deployment import Deployment, DeploymentDiff
|
|
from app.models.deployment_job import DeploymentJob, DeploymentJobLog
|
|
from app.models.system_settings import SystemSettings
|
|
from app.models.audit_log import AuditLog
|
|
from app.models.metrics_history import MetricsHistory
|
|
from app.models.workflow import Workflow, WorkflowExecution, WorkflowLog
|
|
from app.models.webhook import GitWebhook, WebhookLog, GitDeployment
|
|
from app.models.server import Server, ServerGroup, ServerMetrics, ServerCommand, AgentSession, AgentVersion, AgentRollout
|
|
from app.models.security_alert import SecurityAlert
|
|
from app.models.wordpress_site import WordPressSite, DatabaseSnapshot, SyncJob, WordPressVulnerability
|
|
from app.models.environment_activity import EnvironmentActivity
|
|
from app.models.promotion_job import PromotionJob
|
|
from app.models.sanitization_profile import SanitizationProfile
|
|
from app.models.email import EmailDomain, EmailAccount, EmailAlias, EmailForwardingRule, DNSProviderConfig
|
|
from app.models.oauth_identity import OAuthIdentity
|
|
from app.models.source_connection import SourceConnection
|
|
from app.models.api_key import ApiKey
|
|
from app.models.api_usage import ApiUsageLog, ApiUsageSummary
|
|
from app.models.event_subscription import EventSubscription, EventDelivery
|
|
from app.models.invitation import Invitation
|
|
from app.models.metric_alert import ServerAlertThreshold, MetricAlert
|
|
from app.models.agent_plugin import AgentPlugin, AgentPluginInstall
|
|
from app.models.server_template import ServerTemplate, ServerTemplateAssignment
|
|
from app.models.workspace import Workspace, WorkspaceMember, WorkspaceApiKey, ResourceGrant
|
|
from app.models.dns_zone import DNSZone, DNSRecord
|
|
from app.models.status_page import StatusPage, StatusComponent, HealthCheck, StatusIncident, StatusIncidentUpdate
|
|
from app.models.cloud_server import CloudProvider, CloudServer, CloudSnapshot
|
|
from app.models.marketplace import Extension, ExtensionInstall
|
|
from app.models.pending_agent import PendingAgent
|
|
from app.models.plugin import InstalledPlugin
|
|
from app.models.ai import AiConversation, AiMessage, AiPendingAction
|
|
|
|
__all__ = [
|
|
'User', 'Application', 'Domain', 'EnvironmentVariable', 'EnvironmentVariableHistory',
|
|
'NotificationPreferences', 'Deployment', 'DeploymentDiff', 'DeploymentJob', 'DeploymentJobLog', 'SystemSettings', 'AuditLog',
|
|
'MetricsHistory', 'Workflow', 'WorkflowExecution', 'WorkflowLog', 'GitWebhook', 'WebhookLog', 'GitDeployment',
|
|
'Server', 'ServerGroup', 'ServerMetrics', 'ServerCommand', 'AgentSession', 'AgentVersion', 'AgentRollout', 'SecurityAlert',
|
|
'WordPressSite', 'DatabaseSnapshot', 'SyncJob', 'WordPressVulnerability',
|
|
'EnvironmentActivity', 'PromotionJob', 'SanitizationProfile',
|
|
'EmailDomain', 'EmailAccount', 'EmailAlias', 'EmailForwardingRule', 'DNSProviderConfig',
|
|
'OAuthIdentity', 'SourceConnection', 'ApiKey', 'ApiUsageLog', 'ApiUsageSummary',
|
|
'EventSubscription', 'EventDelivery', 'Invitation',
|
|
'ServerAlertThreshold', 'MetricAlert',
|
|
'AgentPlugin', 'AgentPluginInstall',
|
|
'ServerTemplate', 'ServerTemplateAssignment',
|
|
'Workspace', 'WorkspaceMember', 'WorkspaceApiKey', 'ResourceGrant',
|
|
'DNSZone', 'DNSRecord',
|
|
'StatusPage', 'StatusComponent', 'HealthCheck', 'StatusIncident', 'StatusIncidentUpdate',
|
|
'CloudProvider', 'CloudServer', 'CloudSnapshot',
|
|
'Extension', 'ExtensionInstall',
|
|
'PendingAgent',
|
|
'InstalledPlugin',
|
|
'AiConversation', 'AiMessage', 'AiPendingAction',
|
|
]
|