feat(database): add creation and authorization flows
This commit is contained in:
14 files changed
+1500
-36
No files matched your search
@@ -15,6 +15,18 @@ import type { ConnectionConfig } from "@/types/database";
|
|||||||
import * as api from "@/lib/backend/api";
|
import * as api from "@/lib/backend/api";
|
||||||
import { executeWithProductionSqlGuard } from "@/lib/database/productionExecutionGuard";
|
import { executeWithProductionSqlGuard } from "@/lib/database/productionExecutionGuard";
|
||||||
import { grantsFromQueryResult, resolveDatabaseUserAdminProviderForConnection, type DatabaseUserIdentity, type PrivilegeScope } from "@/lib/database/databaseUserAdmin";
|
import { grantsFromQueryResult, resolveDatabaseUserAdminProviderForConnection, type DatabaseUserIdentity, type PrivilegeScope } from "@/lib/database/databaseUserAdmin";
|
||||||
|
import {
|
||||||
|
authorizationPlanSql,
|
||||||
|
authorizationPlanStatus,
|
||||||
|
authorizationPrivileges,
|
||||||
|
buildCreateUserAuthorizationPlan,
|
||||||
|
executeAuthorizationPlan,
|
||||||
|
type AuthorizationAccountType,
|
||||||
|
type AuthorizationPlan,
|
||||||
|
type AuthorizationPreset,
|
||||||
|
type AuthorizationStepResult,
|
||||||
|
type DatabaseAuthorizationSelection,
|
||||||
|
} from "@/lib/database/databaseAuthorizationPlan";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
connection: ConnectionConfig;
|
connection: ConnectionConfig;
|
||||||
@@ -32,6 +44,7 @@ const search = ref("");
|
|||||||
const loadingUsers = ref(false);
|
const loadingUsers = ref(false);
|
||||||
const loadingGrants = ref(false);
|
const loadingGrants = ref(false);
|
||||||
const applying = ref(false);
|
const applying = ref(false);
|
||||||
|
const preparingCreatePlan = ref(false);
|
||||||
const loadError = ref("");
|
const loadError = ref("");
|
||||||
const grantError = ref("");
|
const grantError = ref("");
|
||||||
|
|
||||||
@@ -39,6 +52,8 @@ const createDialogOpen = ref(false);
|
|||||||
const passwordDialogOpen = ref(false);
|
const passwordDialogOpen = ref(false);
|
||||||
const sqlDialogOpen = ref(false);
|
const sqlDialogOpen = ref(false);
|
||||||
const pendingSql = ref("");
|
const pendingSql = ref("");
|
||||||
|
const pendingPlan = ref<AuthorizationPlan>();
|
||||||
|
const pendingResults = ref<AuthorizationStepResult[]>([]);
|
||||||
const pendingDanger = ref(false);
|
const pendingDanger = ref(false);
|
||||||
const pendingAfterApply = ref<(() => Promise<void>) | undefined>();
|
const pendingAfterApply = ref<(() => Promise<void>) | undefined>();
|
||||||
|
|
||||||
@@ -53,6 +68,12 @@ const privilegeRole = ref("");
|
|||||||
const grantOption = ref(false);
|
const grantOption = ref(false);
|
||||||
const selectedPrivileges = ref<string[]>(["SELECT"]);
|
const selectedPrivileges = ref<string[]>(["SELECT"]);
|
||||||
const createCanLogin = ref(true);
|
const createCanLogin = ref(true);
|
||||||
|
const createAccountType = ref<AuthorizationAccountType>("standard");
|
||||||
|
const createDatabases = ref<string[]>([]);
|
||||||
|
const createDatabasesLoading = ref(false);
|
||||||
|
const createDatabaseSearch = ref("");
|
||||||
|
const createDatabaseAuthorizations = ref<DatabaseAuthorizationSelection[]>([]);
|
||||||
|
let createPlanRequestId = 0;
|
||||||
|
|
||||||
const provider = computed(() => resolveDatabaseUserAdminProviderForConnection(props.connection));
|
const provider = computed(() => resolveDatabaseUserAdminProviderForConnection(props.connection));
|
||||||
const supported = computed(() => provider.value !== null);
|
const supported = computed(() => provider.value !== null);
|
||||||
@@ -83,6 +104,14 @@ const selectedDetail = computed(() => {
|
|||||||
const grantsSqlText = computed(() => grants.value.join("\n") || t("userAdmin.noGrants"));
|
const grantsSqlText = computed(() => grants.value.join("\n") || t("userAdmin.noGrants"));
|
||||||
const highlightedGrantsSql = computed(() => highlight(grantsSqlText.value));
|
const highlightedGrantsSql = computed(() => highlight(grantsSqlText.value));
|
||||||
const highlightedPendingSql = computed(() => highlight(pendingSql.value));
|
const highlightedPendingSql = computed(() => highlight(pendingSql.value));
|
||||||
|
const createAuthorizationPrivileges = computed(() => (provider.value ? authorizationPrivileges(provider.value) : []));
|
||||||
|
const filteredCreateDatabases = computed(() => {
|
||||||
|
const query = createDatabaseSearch.value.trim().toLowerCase();
|
||||||
|
return query ? createDatabases.value.filter((database) => database.toLowerCase().includes(query)) : createDatabases.value;
|
||||||
|
});
|
||||||
|
const selectedCreateDatabaseSet = computed(() => new Set(createDatabaseAuthorizations.value.map((selection) => selection.database)));
|
||||||
|
const createDatabaseAuthorizationsValid = computed(() => createDatabaseAuthorizations.value.every((selection) => selection.preset !== "custom" || (selection.privileges?.length ?? 0) > 0));
|
||||||
|
const pendingStatus = computed(() => (pendingResults.value.length > 0 ? authorizationPlanStatus(pendingResults.value) : undefined));
|
||||||
|
|
||||||
function userKey(user: DatabaseUserIdentity): string {
|
function userKey(user: DatabaseUserIdentity): string {
|
||||||
return `${user.user}\u0000${user.host}`;
|
return `${user.user}\u0000${user.host}`;
|
||||||
@@ -162,8 +191,58 @@ function togglePrivilege(privilege: string) {
|
|||||||
selectedPrivileges.value = Array.from(set);
|
selectedPrivileges.value = Array.from(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function openCreateUserDialog() {
|
||||||
|
createDialogOpen.value = true;
|
||||||
|
createAccountType.value = "standard";
|
||||||
|
createCanLogin.value = true;
|
||||||
|
createPassword.value = "";
|
||||||
|
createDatabaseSearch.value = "";
|
||||||
|
createDatabaseAuthorizations.value = [];
|
||||||
|
if (createDatabasesLoading.value) return;
|
||||||
|
createDatabases.value = [];
|
||||||
|
createDatabasesLoading.value = true;
|
||||||
|
try {
|
||||||
|
await ensureConnection();
|
||||||
|
createDatabases.value = (await api.listDatabases(props.connection.id)).map((database) => database.name);
|
||||||
|
} catch (error: any) {
|
||||||
|
toast(t("userAdmin.loadDatabasesFailed", { message: error?.message || String(error) }), 5000);
|
||||||
|
} finally {
|
||||||
|
createDatabasesLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAuthorization(database: string): DatabaseAuthorizationSelection | undefined {
|
||||||
|
return createDatabaseAuthorizations.value.find((selection) => selection.database === database);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCreateDatabase(database: string) {
|
||||||
|
const existing = createAuthorization(database);
|
||||||
|
if (existing) {
|
||||||
|
createDatabaseAuthorizations.value = createDatabaseAuthorizations.value.filter((selection) => selection.database !== database);
|
||||||
|
} else {
|
||||||
|
createDatabaseAuthorizations.value = [...createDatabaseAuthorizations.value, { database, preset: "readOnly", privileges: ["SELECT"] }];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCreateDatabasePreset(database: string, preset: unknown) {
|
||||||
|
const selection = createAuthorization(database);
|
||||||
|
if (!selection || typeof preset !== "string") return;
|
||||||
|
selection.preset = preset as AuthorizationPreset;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCreateDatabasePrivilege(database: string, privilege: string) {
|
||||||
|
const selection = createAuthorization(database);
|
||||||
|
if (!selection) return;
|
||||||
|
const privileges = new Set(selection.privileges ?? []);
|
||||||
|
if (privileges.has(privilege)) privileges.delete(privilege);
|
||||||
|
else privileges.add(privilege);
|
||||||
|
selection.privileges = Array.from(privileges);
|
||||||
|
}
|
||||||
|
|
||||||
function previewSql(sql: string, options: { danger?: boolean; afterApply?: () => Promise<void> } = {}) {
|
function previewSql(sql: string, options: { danger?: boolean; afterApply?: () => Promise<void> } = {}) {
|
||||||
pendingSql.value = sql;
|
pendingSql.value = sql;
|
||||||
|
pendingPlan.value = undefined;
|
||||||
|
pendingResults.value = [];
|
||||||
pendingDanger.value = !!options.danger;
|
pendingDanger.value = !!options.danger;
|
||||||
pendingAfterApply.value = options.afterApply;
|
pendingAfterApply.value = options.afterApply;
|
||||||
sqlDialogOpen.value = true;
|
sqlDialogOpen.value = true;
|
||||||
@@ -178,12 +257,23 @@ async function applyPendingSql() {
|
|||||||
database: "",
|
database: "",
|
||||||
sql: pendingSql.value,
|
sql: pendingSql.value,
|
||||||
source: t("production.sourceAdmin"),
|
source: t("production.sourceAdmin"),
|
||||||
execute: () => api.executeMulti(props.connection.id, "", pendingSql.value, undefined, undefined, { maxRows: 1000 }),
|
execute: async () => {
|
||||||
|
if (pendingPlan.value) {
|
||||||
|
return executeAuthorizationPlan(pendingPlan.value, (step) => api.executeMulti(props.connection.id, step.database, step.sql, undefined, undefined, { maxRows: 1000, continueOnError: true }));
|
||||||
|
}
|
||||||
|
const queryResults = await api.executeMulti(props.connection.id, "", pendingSql.value, undefined, undefined, { maxRows: 1000, continueOnError: true });
|
||||||
|
const failed = queryResults.find((item) => item.execution_error === true);
|
||||||
|
if (failed) throw new Error(String(failed.rows[0]?.[0] ?? t("userAdmin.applyFailedUnknown")));
|
||||||
|
return [] as AuthorizationStepResult[];
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
toast(t("userAdmin.applySuccess"), 2500);
|
pendingResults.value = result;
|
||||||
sqlDialogOpen.value = false;
|
const status = result.length > 0 ? authorizationPlanStatus(result) : "success";
|
||||||
await (pendingAfterApply.value?.() ?? Promise.resolve());
|
toast(t(status === "success" ? "userAdmin.applySuccess" : status === "partial" ? "userAdmin.applyPartial" : "userAdmin.applyFailedSummary"), status === "success" ? 2500 : 5000);
|
||||||
|
const createSucceeded = !pendingPlan.value || result.some((item) => item.step.id === "create-user" && item.status === "success");
|
||||||
|
if (createSucceeded) await (pendingAfterApply.value?.() ?? Promise.resolve());
|
||||||
|
if (!pendingPlan.value) sqlDialogOpen.value = false;
|
||||||
await loadUsers();
|
await loadUsers();
|
||||||
await loadGrants();
|
await loadGrants();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@@ -193,25 +283,81 @@ async function applyPendingSql() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function previewCreateUser() {
|
async function previewCreateUser() {
|
||||||
const userProvider = provider.value;
|
const userProvider = provider.value;
|
||||||
const createUserSql = userProvider?.createUserSql;
|
if (!userProvider?.createUserSql || preparingCreatePlan.value) return;
|
||||||
if (!createUserSql) return;
|
if (!createUser.value.trim() || !createPassword.value || !createDatabaseAuthorizationsValid.value) return;
|
||||||
if (!createUser.value.trim() || !createPassword.value) return;
|
const requestId = ++createPlanRequestId;
|
||||||
previewSql(
|
preparingCreatePlan.value = true;
|
||||||
createUserSql({
|
try {
|
||||||
|
const principal = {
|
||||||
user: createUser.value.trim(),
|
user: createUser.value.trim(),
|
||||||
host: createHost.value.trim() || "%",
|
host: createHost.value.trim() || "%",
|
||||||
password: createPassword.value,
|
password: createPassword.value,
|
||||||
canLogin: createCanLogin.value,
|
canLogin: createCanLogin.value,
|
||||||
}),
|
};
|
||||||
{
|
const databases =
|
||||||
afterApply: async () => {
|
createAccountType.value === "standard" && userProvider.dialect === "postgres"
|
||||||
createDialogOpen.value = false;
|
? await Promise.all(
|
||||||
createPassword.value = "";
|
createDatabaseAuthorizations.value.map(async (selection) => ({
|
||||||
},
|
...selection,
|
||||||
},
|
schemas: await api.listSchemas(props.connection.id, selection.database),
|
||||||
);
|
})),
|
||||||
|
)
|
||||||
|
: createAccountType.value === "standard"
|
||||||
|
? createDatabaseAuthorizations.value
|
||||||
|
: [];
|
||||||
|
if (requestId !== createPlanRequestId || !createDialogOpen.value) return;
|
||||||
|
const plan = buildCreateUserAuthorizationPlan({
|
||||||
|
provider: userProvider,
|
||||||
|
principal,
|
||||||
|
accountType: createAccountType.value,
|
||||||
|
databases,
|
||||||
|
});
|
||||||
|
pendingPlan.value = plan;
|
||||||
|
pendingSql.value = authorizationPlanSql(plan);
|
||||||
|
pendingResults.value = [];
|
||||||
|
pendingDanger.value = createAccountType.value === "admin";
|
||||||
|
pendingAfterApply.value = async () => {
|
||||||
|
createDialogOpen.value = false;
|
||||||
|
createPassword.value = "";
|
||||||
|
selectedUserKey.value = userKey({ user: principal.user, host: isPostgres.value ? (principal.canLogin ? "LOGIN" : "ROLE") : principal.host });
|
||||||
|
};
|
||||||
|
sqlDialogOpen.value = true;
|
||||||
|
} catch (error: any) {
|
||||||
|
if (requestId === createPlanRequestId) toast(t("userAdmin.prepareAuthorizationFailed", { message: error?.message || String(error) }), 5000);
|
||||||
|
} finally {
|
||||||
|
if (requestId === createPlanRequestId) preparingCreatePlan.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function authorizationStepLabel(result: AuthorizationStepResult): string {
|
||||||
|
const step = result.step;
|
||||||
|
if (step.operation === "createUser") return t("userAdmin.stepCreateUser");
|
||||||
|
if (step.operation === "grantAdmin") return t("userAdmin.stepGrantAdmin", { user: step.subject });
|
||||||
|
if (step.operation === "grantDatabase") return t("userAdmin.stepGrantDatabase", { user: step.subject, database: step.targetDatabase });
|
||||||
|
if (step.operation === "grantCurrentObjects") {
|
||||||
|
return t("userAdmin.stepGrantCurrentObjects", {
|
||||||
|
user: step.subject,
|
||||||
|
database: step.targetDatabase,
|
||||||
|
schema: step.schema,
|
||||||
|
scope: authorizationObjectScopeLabel(step.objectScope),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (step.operation === "grantFutureObjects") {
|
||||||
|
return step.owner
|
||||||
|
? t("userAdmin.stepGrantFutureObjectsForOwner", { user: step.subject, database: step.targetDatabase, owner: step.owner, scope: authorizationObjectScopeLabel(step.objectScope) })
|
||||||
|
: t("userAdmin.stepGrantFutureObjects", { user: step.subject, database: step.targetDatabase, scope: authorizationObjectScopeLabel(step.objectScope) });
|
||||||
|
}
|
||||||
|
return step.label;
|
||||||
|
}
|
||||||
|
|
||||||
|
function authorizationObjectScopeLabel(scope: AuthorizationStepResult["step"]["objectScope"]): string {
|
||||||
|
if (scope === "schemas") return t("userAdmin.scopeSchemas");
|
||||||
|
if (scope === "tables") return t("userAdmin.scopeTables");
|
||||||
|
if (scope === "sequences") return t("userAdmin.scopeSequences");
|
||||||
|
if (scope === "functions") return t("userAdmin.scopeFunctions");
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function previewPasswordChange() {
|
function previewPasswordChange() {
|
||||||
@@ -291,6 +437,15 @@ function resetPrivilegeDefaults(scope: PrivilegeScope) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => createDialogOpen.value,
|
||||||
|
(open) => {
|
||||||
|
if (open) return;
|
||||||
|
createPlanRequestId += 1;
|
||||||
|
preparingCreatePlan.value = false;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => selectedUserKey.value,
|
() => selectedUserKey.value,
|
||||||
() => void loadGrants(),
|
() => void loadGrants(),
|
||||||
@@ -300,6 +455,8 @@ watch(
|
|||||||
() => props.connection.id,
|
() => props.connection.id,
|
||||||
() => {
|
() => {
|
||||||
users.value = [];
|
users.value = [];
|
||||||
|
createDatabases.value = [];
|
||||||
|
createDatabaseAuthorizations.value = [];
|
||||||
selectedUserKey.value = "";
|
selectedUserKey.value = "";
|
||||||
grants.value = [];
|
grants.value = [];
|
||||||
privilegeScope.value = provider.value?.defaultScope ?? "mysql";
|
privilegeScope.value = provider.value?.defaultScope ?? "mysql";
|
||||||
@@ -339,7 +496,7 @@ onMounted(loadUsers);
|
|||||||
<RefreshCcw v-else class="h-3.5 w-3.5" />
|
<RefreshCcw v-else class="h-3.5 w-3.5" />
|
||||||
{{ t("grid.refresh") }}
|
{{ t("grid.refresh") }}
|
||||||
</Button>
|
</Button>
|
||||||
<Button v-if="canCreateUser" size="sm" class="h-7 gap-1.5 px-2 text-xs" @click="createDialogOpen = true">
|
<Button v-if="canCreateUser" size="sm" class="h-7 gap-1.5 px-2 text-xs" @click="openCreateUserDialog">
|
||||||
<Plus class="h-3.5 w-3.5" />
|
<Plus class="h-3.5 w-3.5" />
|
||||||
{{ t("userAdmin.newUser") }}
|
{{ t("userAdmin.newUser") }}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -508,11 +665,21 @@ onMounted(loadUsers);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Dialog v-model:open="createDialogOpen">
|
<Dialog v-model:open="createDialogOpen">
|
||||||
<DialogContent class="max-w-sm">
|
<DialogContent class="max-w-2xl">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>{{ t("userAdmin.newUser") }}</DialogTitle>
|
<DialogTitle>{{ t("userAdmin.newUser") }}</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div class="space-y-3">
|
<div class="grid max-h-[70vh] gap-4 overflow-auto pr-1">
|
||||||
|
<div class="grid grid-cols-2 gap-2">
|
||||||
|
<button type="button" class="rounded-md border p-3 text-left" :class="createAccountType === 'standard' ? 'border-primary bg-primary/5' : 'hover:bg-muted/40'" @click="createAccountType = 'standard'">
|
||||||
|
<span class="block text-sm font-medium">{{ t("userAdmin.standardUser") }}</span>
|
||||||
|
<span class="mt-1 block text-xs text-muted-foreground">{{ t("userAdmin.standardUserHint") }}</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="rounded-md border p-3 text-left" :class="createAccountType === 'admin' ? 'border-destructive bg-destructive/5' : 'hover:bg-muted/40'" @click="createAccountType = 'admin'">
|
||||||
|
<span class="block text-sm font-medium">{{ t("userAdmin.adminUser") }}</span>
|
||||||
|
<span class="mt-1 block text-xs text-muted-foreground">{{ t("userAdmin.adminUserHint") }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<label class="block text-xs font-medium">{{ createNameLabel }}</label>
|
<label class="block text-xs font-medium">{{ createNameLabel }}</label>
|
||||||
<Input v-model="createUser" />
|
<Input v-model="createUser" />
|
||||||
<template v-if="!isPostgres">
|
<template v-if="!isPostgres">
|
||||||
@@ -525,10 +692,71 @@ onMounted(loadUsers);
|
|||||||
</label>
|
</label>
|
||||||
<label class="block text-xs font-medium">{{ t("connection.password") }}</label>
|
<label class="block text-xs font-medium">{{ t("connection.password") }}</label>
|
||||||
<PasswordInput v-model="createPassword" />
|
<PasswordInput v-model="createPassword" />
|
||||||
|
|
||||||
|
<div v-if="createAccountType === 'admin'" class="rounded-md border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive">
|
||||||
|
{{ t("userAdmin.adminUserWarning") }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="grid gap-2">
|
||||||
|
<div class="flex items-center justify-between gap-3">
|
||||||
|
<div>
|
||||||
|
<div class="text-xs font-medium">{{ t("userAdmin.databaseAccess") }}</div>
|
||||||
|
<div class="mt-1 text-[11px] text-muted-foreground">{{ t("userAdmin.databaseAccessHint") }}</div>
|
||||||
|
</div>
|
||||||
|
<Badge variant="outline">{{ t("userAdmin.selectedDatabaseCount", { count: createDatabaseAuthorizations.length }) }}</Badge>
|
||||||
|
</div>
|
||||||
|
<div class="flex h-8 items-center gap-2 rounded-md border px-2">
|
||||||
|
<Search class="h-3.5 w-3.5 text-muted-foreground" />
|
||||||
|
<input v-model="createDatabaseSearch" class="min-w-0 flex-1 bg-transparent text-xs outline-none" :placeholder="t('userAdmin.searchDatabase')" />
|
||||||
|
</div>
|
||||||
|
<div class="max-h-64 overflow-auto rounded-md border">
|
||||||
|
<div v-if="createDatabasesLoading" class="flex items-center gap-2 p-3 text-xs text-muted-foreground">
|
||||||
|
<Loader2 class="h-3.5 w-3.5 animate-spin" />
|
||||||
|
{{ t("userAdmin.loadingDatabases") }}
|
||||||
|
</div>
|
||||||
|
<div v-else-if="filteredCreateDatabases.length === 0" class="p-3 text-center text-xs text-muted-foreground">{{ t("userAdmin.emptyDatabases") }}</div>
|
||||||
|
<div v-for="database in filteredCreateDatabases" :key="database" class="border-b p-2 last:border-b-0">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input :checked="selectedCreateDatabaseSet.has(database)" type="checkbox" class="h-3.5 w-3.5 accent-primary" @change="toggleCreateDatabase(database)" />
|
||||||
|
<button type="button" class="min-w-0 flex-1 truncate text-left text-xs font-medium" @click="toggleCreateDatabase(database)">{{ database }}</button>
|
||||||
|
<Select v-if="selectedCreateDatabaseSet.has(database)" :model-value="createAuthorization(database)?.preset" @update:model-value="updateCreateDatabasePreset(database, $event)">
|
||||||
|
<SelectTrigger class="h-7 w-32 text-xs"><SelectValue /></SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="readWrite">{{ t("userAdmin.presetReadWrite") }}</SelectItem>
|
||||||
|
<SelectItem value="readOnly">{{ t("userAdmin.presetReadOnly") }}</SelectItem>
|
||||||
|
<SelectItem value="ddl">{{ t("userAdmin.presetDdl") }}</SelectItem>
|
||||||
|
<SelectItem value="dml">{{ t("userAdmin.presetDml") }}</SelectItem>
|
||||||
|
<SelectItem value="custom">{{ t("userAdmin.presetCustom") }}</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div v-if="createAuthorization(database)?.preset === 'custom'" class="mt-2 grid grid-cols-3 gap-1.5 pl-5">
|
||||||
|
<button
|
||||||
|
v-for="privilege in createAuthorizationPrivileges"
|
||||||
|
:key="privilege"
|
||||||
|
type="button"
|
||||||
|
class="flex h-7 items-center gap-1.5 rounded border px-2 text-[10px]"
|
||||||
|
:class="createAuthorization(database)?.privileges?.includes(privilege) ? 'border-primary bg-primary/10 text-primary' : 'bg-background'"
|
||||||
|
@click="toggleCreateDatabasePrivilege(database, privilege)"
|
||||||
|
>
|
||||||
|
<Check v-if="createAuthorization(database)?.privileges?.includes(privilege)" class="h-3 w-3" />
|
||||||
|
<span class="truncate">{{ privilege }}</span>
|
||||||
|
</button>
|
||||||
|
<p v-if="!createAuthorization(database)?.privileges?.length" class="col-span-3 text-[10px] text-destructive">
|
||||||
|
{{ t("userAdmin.customPrivilegeRequired") }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<p v-if="isPostgres && selectedCreateDatabaseSet.has(database) && createAuthorization(database)?.preset === 'ddl'" class="mt-2 pl-5 text-[10px] text-muted-foreground">
|
||||||
|
{{ t("userAdmin.postgresDdlHint") }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button variant="outline" @click="createDialogOpen = false">{{ t("dangerDialog.cancel") }}</Button>
|
<Button variant="outline" @click="createDialogOpen = false">{{ t("dangerDialog.cancel") }}</Button>
|
||||||
<Button :disabled="!createUser.trim() || !createPassword" @click="previewCreateUser">
|
<Button :disabled="!createUser.trim() || !createPassword || !createDatabaseAuthorizationsValid || preparingCreatePlan" @click="previewCreateUser">
|
||||||
|
<Loader2 v-if="preparingCreatePlan" class="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||||
{{ t("userAdmin.previewSql") }}
|
{{ t("userAdmin.previewSql") }}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
@@ -557,12 +785,30 @@ onMounted(loadUsers);
|
|||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<pre class="max-h-[50vh] min-h-44 overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 font-mono text-xs leading-5" v-html="highlightedPendingSql" />
|
<pre class="max-h-[50vh] min-h-44 overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 font-mono text-xs leading-5" v-html="highlightedPendingSql" />
|
||||||
|
<div v-if="pendingResults.length > 0" class="grid gap-2 rounded-md border p-3">
|
||||||
|
<div class="text-xs font-semibold" :class="pendingStatus === 'success' ? 'text-green-600' : pendingStatus === 'partial' ? 'text-amber-600' : 'text-destructive'">
|
||||||
|
{{ t(pendingStatus === "success" ? "userAdmin.resultSuccess" : pendingStatus === "partial" ? "userAdmin.resultPartial" : "userAdmin.resultFailed") }}
|
||||||
|
</div>
|
||||||
|
<div v-for="result in pendingResults" :key="result.step.id" class="flex items-start gap-2 text-xs">
|
||||||
|
<Check v-if="result.status === 'success'" class="mt-0.5 h-3.5 w-3.5 shrink-0 text-green-600" />
|
||||||
|
<AlertTriangle v-else-if="result.status === 'failed'" class="mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive" />
|
||||||
|
<span v-else class="mt-1 h-2 w-2 shrink-0 rounded-full bg-muted-foreground" />
|
||||||
|
<span class="min-w-0">
|
||||||
|
<span class="block">{{ authorizationStepLabel(result) }}</span>
|
||||||
|
<span v-if="result.message" class="mt-0.5 block break-all text-destructive">{{ result.message }}</span>
|
||||||
|
<span v-else-if="result.status === 'skipped'" class="mt-0.5 block text-muted-foreground">{{ t("userAdmin.stepSkipped") }}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button variant="outline" @click="sqlDialogOpen = false">{{ t("dangerDialog.cancel") }}</Button>
|
<template v-if="pendingResults.length === 0">
|
||||||
<Button :variant="pendingDanger ? 'destructive' : 'default'" :disabled="applying" @click="applyPendingSql">
|
<Button variant="outline" @click="sqlDialogOpen = false">{{ t("dangerDialog.cancel") }}</Button>
|
||||||
<Loader2 v-if="applying" class="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
<Button :variant="pendingDanger ? 'destructive' : 'default'" :disabled="applying" @click="applyPendingSql">
|
||||||
{{ t("userAdmin.applySql") }}
|
<Loader2 v-if="applying" class="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||||
</Button>
|
{{ t("userAdmin.applySql") }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<Button v-else @click="sqlDialogOpen = false">{{ t("userAdmin.closeResult") }}</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { toRefs, watch } from "vue";
|
import { toRefs, watch } from "vue";
|
||||||
import { Loader2, Clipboard, Upload } from "@lucide/vue";
|
import { AlertTriangle, Check, Loader2, Clipboard, Upload } from "@lucide/vue";
|
||||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
@@ -55,6 +55,19 @@ const {
|
|||||||
createDatabaseCollation,
|
createDatabaseCollation,
|
||||||
createDatabaseCollationOptionsForCharset,
|
createDatabaseCollationOptionsForCharset,
|
||||||
createDatabaseCollationsByCharset,
|
createDatabaseCollationsByCharset,
|
||||||
|
createDatabaseUsers,
|
||||||
|
createDatabaseSelectedUsers,
|
||||||
|
createDatabaseUsersLoading,
|
||||||
|
createDatabaseUserKey,
|
||||||
|
createDatabaseUserLabel,
|
||||||
|
createDatabaseUserSelected,
|
||||||
|
toggleCreateDatabaseUser,
|
||||||
|
showCreateDatabasePreviewDialog,
|
||||||
|
createDatabasePreviewSql,
|
||||||
|
createDatabaseAuthorizationResults,
|
||||||
|
createDatabaseAuthorizationApplying,
|
||||||
|
applyCreateDatabaseAuthorizationPlan,
|
||||||
|
createDatabaseAuthorizationStepLabel,
|
||||||
confirmCreateDatabase,
|
confirmCreateDatabase,
|
||||||
showEditDatabasePropertiesDialog,
|
showEditDatabasePropertiesDialog,
|
||||||
editDatabasePropertiesLoading,
|
editDatabasePropertiesLoading,
|
||||||
@@ -93,6 +106,28 @@ function pasteTargetsMissing(entries: Array<{ targetName: string }>): boolean {
|
|||||||
return entries.every((entry) => !entry.targetName.trim());
|
return entries.every((entry) => !entry.targetName.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function returnToCreateDatabaseDialog() {
|
||||||
|
showCreateDatabaseDialog.value = true;
|
||||||
|
showCreateDatabasePreviewDialog.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCreateDatabasePreviewDialog(open: boolean) {
|
||||||
|
if (open) {
|
||||||
|
showCreateDatabasePreviewDialog.value = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (createDatabaseAuthorizationApplying.value) return;
|
||||||
|
if (createDatabaseAuthorizationResults.value.length === 0) {
|
||||||
|
returnToCreateDatabaseDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showCreateDatabasePreviewDialog.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCreateDatabaseResult() {
|
||||||
|
showCreateDatabasePreviewDialog.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[
|
[
|
||||||
showDeleteConfirm,
|
showDeleteConfirm,
|
||||||
@@ -104,6 +139,7 @@ watch(
|
|||||||
showDuplicateDialog,
|
showDuplicateDialog,
|
||||||
showPasteDialog,
|
showPasteDialog,
|
||||||
showCreateDatabaseDialog,
|
showCreateDatabaseDialog,
|
||||||
|
showCreateDatabasePreviewDialog,
|
||||||
showEditDatabasePropertiesDialog,
|
showEditDatabasePropertiesDialog,
|
||||||
showCreateNacosNamespaceDialog,
|
showCreateNacosNamespaceDialog,
|
||||||
showEditNacosNamespaceDialog,
|
showEditNacosNamespaceDialog,
|
||||||
@@ -331,9 +367,63 @@ watch(
|
|||||||
</SearchableSelect>
|
</SearchableSelect>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="createDatabaseUsersLoading || createDatabaseUsers.length > 0" class="grid gap-2">
|
||||||
|
<div class="flex items-center justify-between gap-2">
|
||||||
|
<div>
|
||||||
|
<div class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.createDatabaseUsers") }}</div>
|
||||||
|
<div class="mt-1 text-[11px] text-muted-foreground">{{ t("contextMenu.createDatabaseUsersHint") }}</div>
|
||||||
|
</div>
|
||||||
|
<span class="text-[11px] text-muted-foreground">{{ t("contextMenu.createDatabaseUsersSelected", { count: createDatabaseSelectedUsers.length }) }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="max-h-40 overflow-auto rounded-md border">
|
||||||
|
<div v-if="createDatabaseUsersLoading" class="flex items-center gap-2 p-3 text-xs text-muted-foreground">
|
||||||
|
<Loader2 class="h-3.5 w-3.5 animate-spin" />
|
||||||
|
{{ t("contextMenu.createDatabaseUsersLoading") }}
|
||||||
|
</div>
|
||||||
|
<template v-else>
|
||||||
|
<button v-for="user in createDatabaseUsers" :key="createDatabaseUserKey(user)" type="button" class="flex w-full items-center gap-2 border-b px-3 py-2 text-left text-xs last:border-b-0 hover:bg-muted/50" @click="toggleCreateDatabaseUser(user)">
|
||||||
|
<span class="flex h-3.5 w-3.5 items-center justify-center rounded border" :class="createDatabaseUserSelected(user) ? 'border-primary bg-primary text-primary-foreground' : 'border-border'">
|
||||||
|
<Check v-if="createDatabaseUserSelected(user)" class="h-2.5 w-2.5" />
|
||||||
|
</span>
|
||||||
|
<span class="truncate">{{ createDatabaseUserLabel(user) }}</span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button variant="outline" @click="showCreateDatabaseDialog = false">{{ t("dangerDialog.cancel") }}</Button>
|
<Button variant="outline" @click="showCreateDatabaseDialog = false">{{ t("dangerDialog.cancel") }}</Button>
|
||||||
<Button :disabled="!createDatabaseName.trim()" @click="confirmCreateDatabase">{{ t("dangerDialog.confirm") }}</Button>
|
<Button :disabled="!createDatabaseName.trim()" @click="confirmCreateDatabase">{{ t("contextMenu.previewCreateDatabaseSql") }}</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
|
<Dialog :open="showCreateDatabasePreviewDialog" @update:open="updateCreateDatabasePreviewDialog">
|
||||||
|
<DialogContent class="sm:max-w-[720px]">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>{{ t("contextMenu.createDatabaseSqlPreview") }}</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
<pre class="max-h-[48vh] min-h-44 overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 font-mono text-xs leading-5" v-html="highlight(createDatabasePreviewSql)" />
|
||||||
|
<div v-if="createDatabaseAuthorizationResults.length > 0" class="grid gap-2 rounded-md border p-3">
|
||||||
|
<div v-for="result in createDatabaseAuthorizationResults" :key="result.step.id" class="flex items-start gap-2 text-xs">
|
||||||
|
<Check v-if="result.status === 'success'" class="mt-0.5 h-3.5 w-3.5 shrink-0 text-green-600" />
|
||||||
|
<AlertTriangle v-else-if="result.status === 'failed'" class="mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive" />
|
||||||
|
<span v-else class="mt-1 h-2 w-2 shrink-0 rounded-full bg-muted-foreground" />
|
||||||
|
<span class="min-w-0">
|
||||||
|
<span class="block">{{ createDatabaseAuthorizationStepLabel(result) }}</span>
|
||||||
|
<span v-if="result.message" class="mt-0.5 block break-all text-destructive">{{ result.message }}</span>
|
||||||
|
<span v-else-if="result.status === 'skipped'" class="mt-0.5 block text-muted-foreground">{{ t("contextMenu.createDatabaseStepSkipped") }}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<DialogFooter>
|
||||||
|
<template v-if="createDatabaseAuthorizationResults.length === 0">
|
||||||
|
<Button variant="outline" :disabled="createDatabaseAuthorizationApplying" @click="updateCreateDatabasePreviewDialog(false)">{{ t("dangerDialog.cancel") }}</Button>
|
||||||
|
<Button :disabled="createDatabaseAuthorizationApplying" @click="applyCreateDatabaseAuthorizationPlan">
|
||||||
|
<Loader2 v-if="createDatabaseAuthorizationApplying" class="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||||
|
{{ t("contextMenu.applyCreateDatabaseSql") }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<Button v-else @click="closeCreateDatabaseResult">{{ t("contextMenu.closeCreateDatabaseResult") }}</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -147,7 +147,8 @@ import { sidebarDisplayTableName } from "@/lib/sidebar/sidebarTableNameDisplay";
|
|||||||
import { shouldMeasureSidebarLabelOverflow } from "@/lib/sidebar/sidebarLabelTooltip";
|
import { shouldMeasureSidebarLabelOverflow } from "@/lib/sidebar/sidebarLabelTooltip";
|
||||||
import { selectedTreeNodesInVisibleOrder as orderSelectedTreeNodes, treeSelectionRangeIdsByIndex, treeSelectionRangeIds } from "@/lib/sidebar/sidebarTreeSelection";
|
import { selectedTreeNodesInVisibleOrder as orderSelectedTreeNodes, treeSelectionRangeIdsByIndex, treeSelectionRangeIds } from "@/lib/sidebar/sidebarTreeSelection";
|
||||||
import { connectionPasteTargetGroupId, selectedConnectionClipboardTargets, selectedConnectionDeleteTargets, selectedConnectionDuplicateTargets, selectedConnectionEditTarget } from "@/lib/sidebar/sidebarConnectionSelection";
|
import { connectionPasteTargetGroupId, selectedConnectionClipboardTargets, selectedConnectionDeleteTargets, selectedConnectionDuplicateTargets, selectedConnectionEditTarget } from "@/lib/sidebar/sidebarConnectionSelection";
|
||||||
import { connectionSupportsDatabaseUserAdmin } from "@/lib/database/databaseUserAdmin";
|
import { connectionSupportsDatabaseUserAdmin, resolveDatabaseUserAdminProviderForConnection, type DatabaseUserIdentity } from "@/lib/database/databaseUserAdmin";
|
||||||
|
import { authorizationPlanSql, authorizationPlanStatus, buildCreateDatabaseAuthorizationPlan, executeAuthorizationPlan, type AuthorizationPlan, type AuthorizationStepResult } from "@/lib/database/databaseAuthorizationPlan";
|
||||||
import { connectionSupportsProcessList } from "@/lib/database/processListDrivers";
|
import { connectionSupportsProcessList } from "@/lib/database/processListDrivers";
|
||||||
import { connectionSupportsServerDashboard } from "@/lib/database/mysqlServerStatus";
|
import { connectionSupportsServerDashboard } from "@/lib/database/mysqlServerStatus";
|
||||||
import { connectionSupportsServerDashboard as connectionSupportsPgServerDashboard } from "@/lib/database/postgresServerStatus";
|
import { connectionSupportsServerDashboard as connectionSupportsPgServerDashboard } from "@/lib/database/postgresServerStatus";
|
||||||
@@ -230,6 +231,14 @@ import {
|
|||||||
createDatabaseName,
|
createDatabaseName,
|
||||||
createDatabaseCharset,
|
createDatabaseCharset,
|
||||||
createDatabaseCollation,
|
createDatabaseCollation,
|
||||||
|
createDatabaseUsers,
|
||||||
|
createDatabaseSelectedUsers,
|
||||||
|
createDatabaseUsersLoading,
|
||||||
|
showCreateDatabasePreviewDialog,
|
||||||
|
createDatabaseAuthorizationPlan,
|
||||||
|
createDatabasePreviewSql,
|
||||||
|
createDatabaseAuthorizationResults,
|
||||||
|
createDatabaseAuthorizationApplying,
|
||||||
showCreateNacosNamespaceDialog,
|
showCreateNacosNamespaceDialog,
|
||||||
createNacosNamespaceId,
|
createNacosNamespaceId,
|
||||||
createNacosNamespaceName,
|
createNacosNamespaceName,
|
||||||
@@ -3126,12 +3135,76 @@ function openCreateDatabaseDialog() {
|
|||||||
createDatabaseName.value = "";
|
createDatabaseName.value = "";
|
||||||
createDatabaseCharset.value = "utf8mb4";
|
createDatabaseCharset.value = "utf8mb4";
|
||||||
createDatabaseCollation.value = "utf8mb4_unicode_ci";
|
createDatabaseCollation.value = "utf8mb4_unicode_ci";
|
||||||
|
createDatabaseUsers.value = [];
|
||||||
|
createDatabaseSelectedUsers.value = [];
|
||||||
|
createDatabaseUsersLoading.value = false;
|
||||||
|
createDatabaseAuthorizationPlan.value = undefined;
|
||||||
|
createDatabasePreviewSql.value = "";
|
||||||
|
createDatabaseAuthorizationResults.value = [];
|
||||||
createDatabaseCharsetOptions.value = fallbackCreateDatabaseCharset.charsets;
|
createDatabaseCharsetOptions.value = fallbackCreateDatabaseCharset.charsets;
|
||||||
createDatabaseCollationsByCharset.value = fallbackCreateDatabaseCharset.collationsByCharset;
|
createDatabaseCollationsByCharset.value = fallbackCreateDatabaseCharset.collationsByCharset;
|
||||||
showCreateDatabaseDialog.value = true;
|
showCreateDatabaseDialog.value = true;
|
||||||
if (canSetCreateDatabaseCharset.value) {
|
if (canSetCreateDatabaseCharset.value) {
|
||||||
void loadCreateDatabaseCharsetMetadata();
|
void loadCreateDatabaseCharsetMetadata();
|
||||||
}
|
}
|
||||||
|
void loadCreateDatabaseUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
let createDatabaseUsersRequestId = 0;
|
||||||
|
|
||||||
|
async function loadCreateDatabaseUsers() {
|
||||||
|
const node = sidebarFormTarget.value ?? props.node;
|
||||||
|
if (!node.connectionId) return;
|
||||||
|
const connectionId = node.connectionId;
|
||||||
|
const requestId = ++createDatabaseUsersRequestId;
|
||||||
|
const requestOwner = sidebarTreeDialogOwner.value;
|
||||||
|
const requestIsActive = () => requestId === createDatabaseUsersRequestId && sidebarTreeDialogOwner.value === requestOwner && sidebarFormTarget.value?.connectionId === connectionId && showCreateDatabaseDialog.value;
|
||||||
|
const config = connectionStore.getConfig(node.connectionId);
|
||||||
|
const userProvider = resolveDatabaseUserAdminProviderForConnection(config);
|
||||||
|
if (!userProvider) return;
|
||||||
|
createDatabaseUsersLoading.value = true;
|
||||||
|
try {
|
||||||
|
await connectionStore.ensureConnected(connectionId);
|
||||||
|
try {
|
||||||
|
const result = await api.executeQuery(connectionId, "", userProvider.listUsersSql(), undefined, undefined, { maxRows: 5000 });
|
||||||
|
if (requestIsActive()) createDatabaseUsers.value = userProvider.parseUsers(result);
|
||||||
|
} catch (error) {
|
||||||
|
if (!userProvider.fallbackListUsersSql || !userProvider.parseFallbackUsers) throw error;
|
||||||
|
const result = await api.executeQuery(connectionId, "", userProvider.fallbackListUsersSql(), undefined, undefined, { maxRows: 5000 });
|
||||||
|
if (requestIsActive()) createDatabaseUsers.value = userProvider.parseFallbackUsers(result);
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
if (requestIsActive()) {
|
||||||
|
createDatabaseUsers.value = [];
|
||||||
|
toast(t("contextMenu.createDatabaseUsersLoadFailed", { message: error?.message || String(error) }), 5000);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (requestIsActive()) createDatabaseUsersLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDatabaseUserKey(user: DatabaseUserIdentity): string {
|
||||||
|
return `${user.user}\u0000${user.host}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDatabaseUserLabel(user: DatabaseUserIdentity): string {
|
||||||
|
const node = sidebarFormTarget.value ?? props.node;
|
||||||
|
const provider = resolveDatabaseUserAdminProviderForConnection(connectionStore.getConfig(node.connectionId || ""));
|
||||||
|
return provider?.label(user) ?? user.user;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDatabaseUserSelected(user: DatabaseUserIdentity): boolean {
|
||||||
|
const key = createDatabaseUserKey(user);
|
||||||
|
return createDatabaseSelectedUsers.value.some((selected) => createDatabaseUserKey(selected) === key);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCreateDatabaseUser(user: DatabaseUserIdentity) {
|
||||||
|
const key = createDatabaseUserKey(user);
|
||||||
|
if (createDatabaseSelectedUsers.value.some((selected) => createDatabaseUserKey(selected) === key)) {
|
||||||
|
createDatabaseSelectedUsers.value = createDatabaseSelectedUsers.value.filter((selected) => createDatabaseUserKey(selected) !== key);
|
||||||
|
} else {
|
||||||
|
createDatabaseSelectedUsers.value = [...createDatabaseSelectedUsers.value, user];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openConnectionNamespaceCreation() {
|
function openConnectionNamespaceCreation() {
|
||||||
@@ -3302,11 +3375,11 @@ async function confirmCreateDatabase() {
|
|||||||
const node = sidebarFormTarget.value ?? props.node;
|
const node = sidebarFormTarget.value ?? props.node;
|
||||||
const name = createDatabaseName.value.trim();
|
const name = createDatabaseName.value.trim();
|
||||||
if (!name || !node.connectionId) return;
|
if (!name || !node.connectionId) return;
|
||||||
showCreateDatabaseDialog.value = false;
|
|
||||||
try {
|
try {
|
||||||
await connectionStore.ensureConnected(node.connectionId);
|
await connectionStore.ensureConnected(node.connectionId);
|
||||||
const config = connectionStore.getConfig(node.connectionId);
|
const config = connectionStore.getConfig(node.connectionId);
|
||||||
if (config?.db_type === "mongodb") {
|
if (config?.db_type === "mongodb") {
|
||||||
|
showCreateDatabaseDialog.value = false;
|
||||||
await api.mongoCreateDatabase(node.connectionId, name);
|
await api.mongoCreateDatabase(node.connectionId, name);
|
||||||
toast(t("contextMenu.createDatabaseSuccess", { name }), 3000);
|
toast(t("contextMenu.createDatabaseSuccess", { name }), 3000);
|
||||||
await connectionStore.ensureVisibleDatabase(node.connectionId, name);
|
await connectionStore.ensureVisibleDatabase(node.connectionId, name);
|
||||||
@@ -3321,15 +3394,78 @@ async function confirmCreateDatabase() {
|
|||||||
charset: createDatabaseCharset.value,
|
charset: createDatabaseCharset.value,
|
||||||
collation: createDatabaseCollation.value,
|
collation: createDatabaseCollation.value,
|
||||||
});
|
});
|
||||||
await executeTreeNodeSqlWithProductionGuard(node, sql, { database: "" });
|
const provider = resolveDatabaseUserAdminProviderForConnection(config);
|
||||||
toast(t("contextMenu.createDatabaseSuccess", { name }), 3000);
|
const plan: AuthorizationPlan = provider
|
||||||
await connectionStore.ensureVisibleDatabase(node.connectionId, name);
|
? buildCreateDatabaseAuthorizationPlan({ provider, database: name, createSql: sql, users: createDatabaseSelectedUsers.value })
|
||||||
await connectionStore.loadDatabases(node.connectionId, { force: true });
|
: { steps: [{ id: "create-database", label: `create database ${name}`, database: "", sql, operation: "createDatabase", targetDatabase: name }] };
|
||||||
|
createDatabaseAuthorizationPlan.value = plan;
|
||||||
|
createDatabasePreviewSql.value = authorizationPlanSql(plan);
|
||||||
|
createDatabaseAuthorizationResults.value = [];
|
||||||
|
showCreateDatabaseDialog.value = false;
|
||||||
|
showCreateDatabasePreviewDialog.value = true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("contextMenu.tableOperationFailed", { message: e?.message || String(e) }), 5000);
|
toast(t("contextMenu.tableOperationFailed", { message: e?.message || String(e) }), 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function applyCreateDatabaseAuthorizationPlan() {
|
||||||
|
const node = sidebarFormTarget.value ?? props.node;
|
||||||
|
const plan = createDatabaseAuthorizationPlan.value;
|
||||||
|
const name = createDatabaseName.value.trim();
|
||||||
|
if (!node.connectionId || !plan || createDatabaseAuthorizationApplying.value) return;
|
||||||
|
createDatabaseAuthorizationApplying.value = true;
|
||||||
|
try {
|
||||||
|
const results = await executeWithProductionSqlGuard({
|
||||||
|
connection: connectionStore.getConfig(node.connectionId),
|
||||||
|
database: "",
|
||||||
|
sql: createDatabasePreviewSql.value,
|
||||||
|
source: t("production.sourceSidebar"),
|
||||||
|
execute: () => executeAuthorizationPlan(plan, (step) => api.executeMulti(node.connectionId!, step.database, step.sql, undefined, undefined, { maxRows: 1000, continueOnError: true })),
|
||||||
|
});
|
||||||
|
if (!results) return;
|
||||||
|
createDatabaseAuthorizationResults.value = results;
|
||||||
|
const created = results.some((result) => result.step.id === "create-database" && result.status === "success");
|
||||||
|
const status = authorizationPlanStatus(results);
|
||||||
|
if (created) {
|
||||||
|
await connectionStore.ensureVisibleDatabase(node.connectionId, name);
|
||||||
|
await connectionStore.loadDatabases(node.connectionId, { force: true });
|
||||||
|
}
|
||||||
|
toast(t(status === "success" ? "contextMenu.createDatabaseSuccess" : status === "partial" ? "contextMenu.createDatabasePartial" : "contextMenu.createDatabaseFailed", { name }), status === "success" ? 3000 : 5000);
|
||||||
|
} catch (error: any) {
|
||||||
|
toast(t("contextMenu.tableOperationFailed", { message: error?.message || String(error) }), 5000);
|
||||||
|
} finally {
|
||||||
|
createDatabaseAuthorizationApplying.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDatabaseAuthorizationStepLabel(result: AuthorizationStepResult): string {
|
||||||
|
const step = result.step;
|
||||||
|
if (step.operation === "createDatabase") return t("contextMenu.createDatabaseStep", { database: step.targetDatabase });
|
||||||
|
if (step.operation === "grantDatabase") return t("contextMenu.createDatabaseGrantStep", { user: step.subject, database: step.targetDatabase });
|
||||||
|
if (step.operation === "grantCurrentObjects") {
|
||||||
|
return t("userAdmin.stepGrantCurrentObjects", {
|
||||||
|
user: step.subject,
|
||||||
|
database: step.targetDatabase,
|
||||||
|
schema: step.schema,
|
||||||
|
scope: createDatabaseAuthorizationScopeLabel(step.objectScope),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (step.operation === "grantFutureObjects") {
|
||||||
|
return step.owner
|
||||||
|
? t("userAdmin.stepGrantFutureObjectsForOwner", { user: step.subject, database: step.targetDatabase, owner: step.owner, scope: createDatabaseAuthorizationScopeLabel(step.objectScope) })
|
||||||
|
: t("userAdmin.stepGrantFutureObjects", { user: step.subject, database: step.targetDatabase, scope: createDatabaseAuthorizationScopeLabel(step.objectScope) });
|
||||||
|
}
|
||||||
|
return step.label;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDatabaseAuthorizationScopeLabel(scope: AuthorizationStepResult["step"]["objectScope"]): string {
|
||||||
|
if (scope === "schemas") return t("userAdmin.scopeSchemas");
|
||||||
|
if (scope === "tables") return t("userAdmin.scopeTables");
|
||||||
|
if (scope === "sequences") return t("userAdmin.scopeSequences");
|
||||||
|
if (scope === "functions") return t("userAdmin.scopeFunctions");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
function dropDatabase() {
|
function dropDatabase() {
|
||||||
void refreshDropDatabasePreviewSql();
|
void refreshDropDatabasePreviewSql();
|
||||||
dropDatabaseLoading.value = false;
|
dropDatabaseLoading.value = false;
|
||||||
@@ -4772,6 +4908,19 @@ function getTreeItemDialogController(): Record<string, any> {
|
|||||||
createDatabaseCharsetLoading,
|
createDatabaseCharsetLoading,
|
||||||
normalizeCreateDatabaseCharset,
|
normalizeCreateDatabaseCharset,
|
||||||
createDatabaseCollation,
|
createDatabaseCollation,
|
||||||
|
createDatabaseUsers,
|
||||||
|
createDatabaseSelectedUsers,
|
||||||
|
createDatabaseUsersLoading,
|
||||||
|
createDatabaseUserKey,
|
||||||
|
createDatabaseUserLabel,
|
||||||
|
createDatabaseUserSelected,
|
||||||
|
toggleCreateDatabaseUser,
|
||||||
|
showCreateDatabasePreviewDialog,
|
||||||
|
createDatabasePreviewSql,
|
||||||
|
createDatabaseAuthorizationResults,
|
||||||
|
createDatabaseAuthorizationApplying,
|
||||||
|
applyCreateDatabaseAuthorizationPlan,
|
||||||
|
createDatabaseAuthorizationStepLabel,
|
||||||
createDatabaseCollationOptionsForCharset,
|
createDatabaseCollationOptionsForCharset,
|
||||||
createDatabaseCollationsByCharset,
|
createDatabaseCollationsByCharset,
|
||||||
confirmCreateDatabase,
|
confirmCreateDatabase,
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { ref, shallowRef } from "vue";
|
|||||||
import type { TreeNode } from "@/types/database";
|
import type { TreeNode } from "@/types/database";
|
||||||
import type { PasteTableMode } from "@/lib/table/tableClipboard";
|
import type { PasteTableMode } from "@/lib/table/tableClipboard";
|
||||||
import { fallbackCreateDatabaseCharsetMetadata } from "@/lib/database/createDatabaseCharsetOptions";
|
import { fallbackCreateDatabaseCharsetMetadata } from "@/lib/database/createDatabaseCharsetOptions";
|
||||||
|
import type { DatabaseUserIdentity } from "@/lib/database/databaseUserAdmin";
|
||||||
|
import type { AuthorizationPlan, AuthorizationStepResult } from "@/lib/database/databaseAuthorizationPlan";
|
||||||
|
|
||||||
export type DuplicateStructureSource = TreeNode & { connectionId: string; database: string };
|
export type DuplicateStructureSource = TreeNode & { connectionId: string; database: string };
|
||||||
type ConnectionDeleteTarget = TreeNode & { connectionId: string };
|
type ConnectionDeleteTarget = TreeNode & { connectionId: string };
|
||||||
@@ -61,6 +63,14 @@ export const showCreateDatabaseDialog = ref(false);
|
|||||||
export const createDatabaseName = ref("");
|
export const createDatabaseName = ref("");
|
||||||
export const createDatabaseCharset = ref("utf8mb4");
|
export const createDatabaseCharset = ref("utf8mb4");
|
||||||
export const createDatabaseCollation = ref("utf8mb4_unicode_ci");
|
export const createDatabaseCollation = ref("utf8mb4_unicode_ci");
|
||||||
|
export const createDatabaseUsers = ref<DatabaseUserIdentity[]>([]);
|
||||||
|
export const createDatabaseSelectedUsers = ref<DatabaseUserIdentity[]>([]);
|
||||||
|
export const createDatabaseUsersLoading = ref(false);
|
||||||
|
export const showCreateDatabasePreviewDialog = ref(false);
|
||||||
|
export const createDatabaseAuthorizationPlan = ref<AuthorizationPlan>();
|
||||||
|
export const createDatabasePreviewSql = ref("");
|
||||||
|
export const createDatabaseAuthorizationResults = ref<AuthorizationStepResult[]>([]);
|
||||||
|
export const createDatabaseAuthorizationApplying = ref(false);
|
||||||
export const showCreateNacosNamespaceDialog = ref(false);
|
export const showCreateNacosNamespaceDialog = ref(false);
|
||||||
export const createNacosNamespaceId = ref("");
|
export const createNacosNamespaceId = ref("");
|
||||||
export const createNacosNamespaceName = ref("");
|
export const createNacosNamespaceName = ref("");
|
||||||
@@ -115,6 +125,7 @@ const openFlags = [
|
|||||||
showDuplicateDialog,
|
showDuplicateDialog,
|
||||||
showPasteDialog,
|
showPasteDialog,
|
||||||
showCreateDatabaseDialog,
|
showCreateDatabaseDialog,
|
||||||
|
showCreateDatabasePreviewDialog,
|
||||||
showCreateNacosNamespaceDialog,
|
showCreateNacosNamespaceDialog,
|
||||||
showEditNacosNamespaceDialog,
|
showEditNacosNamespaceDialog,
|
||||||
showDropDatabaseConfirm,
|
showDropDatabaseConfirm,
|
||||||
@@ -132,6 +143,13 @@ const openFlags = [
|
|||||||
|
|
||||||
export function resetSidebarTreeDialogState() {
|
export function resetSidebarTreeDialogState() {
|
||||||
for (const flag of openFlags) flag.value = false;
|
for (const flag of openFlags) flag.value = false;
|
||||||
|
createDatabaseUsers.value = [];
|
||||||
|
createDatabaseSelectedUsers.value = [];
|
||||||
|
createDatabaseUsersLoading.value = false;
|
||||||
|
createDatabaseAuthorizationPlan.value = undefined;
|
||||||
|
createDatabasePreviewSql.value = "";
|
||||||
|
createDatabaseAuthorizationResults.value = [];
|
||||||
|
createDatabaseAuthorizationApplying.value = false;
|
||||||
sidebarTreeDialogOwner.value = null;
|
sidebarTreeDialogOwner.value = null;
|
||||||
sidebarDangerTarget.value = null;
|
sidebarDangerTarget.value = null;
|
||||||
sidebarFormTarget.value = null;
|
sidebarFormTarget.value = null;
|
||||||
|
|||||||
@@ -1716,6 +1716,21 @@ export default {
|
|||||||
confirmDropDatabaseTitle: "Drop Database",
|
confirmDropDatabaseTitle: "Drop Database",
|
||||||
confirmDropDatabaseMessage: 'Are you sure you want to drop database "{name}"? This will permanently delete the database and all its data.',
|
confirmDropDatabaseMessage: 'Are you sure you want to drop database "{name}"? This will permanently delete the database and all its data.',
|
||||||
createDatabaseSuccess: 'Database "{name}" created',
|
createDatabaseSuccess: 'Database "{name}" created',
|
||||||
|
createDatabasePartial: 'Database "{name}" was created, but some grants failed',
|
||||||
|
createDatabaseFailed: 'Database "{name}" could not be created',
|
||||||
|
createDatabaseUsers: "Grant access to users",
|
||||||
|
createDatabaseUsersHint: "Selected users receive full native access after the database is created.",
|
||||||
|
createDatabaseUsersSelected: "{count} selected",
|
||||||
|
createDatabaseUsersLoading: "Loading users...",
|
||||||
|
createDatabaseUsersLoadFailed: "Could not load users: {message}",
|
||||||
|
previewCreateDatabaseSql: "Preview SQL",
|
||||||
|
createDatabaseSqlPreview: "Create Database SQL Preview",
|
||||||
|
applyCreateDatabaseSql: "Create and Grant",
|
||||||
|
closeCreateDatabaseResult: "Close",
|
||||||
|
createDatabaseStep: 'Create database "{database}"',
|
||||||
|
createDatabaseGrantStep: 'Grant database access to {user} on "{database}"',
|
||||||
|
createDatabaseGrantObjectsStep: 'Grant schema and object access to {user} on "{database}"',
|
||||||
|
createDatabaseStepSkipped: "Skipped because a required previous step failed.",
|
||||||
editDatabaseProperties: "Edit Database Properties",
|
editDatabaseProperties: "Edit Database Properties",
|
||||||
editDatabasePropertiesTitle: 'Edit Database Properties: "{name}"',
|
editDatabasePropertiesTitle: 'Edit Database Properties: "{name}"',
|
||||||
editDatabasePropertiesSaving: "Saving...",
|
editDatabasePropertiesSaving: "Saving...",
|
||||||
@@ -1936,7 +1951,46 @@ export default {
|
|||||||
sqlPreview: "SQL Preview",
|
sqlPreview: "SQL Preview",
|
||||||
applySql: "Apply SQL",
|
applySql: "Apply SQL",
|
||||||
applySuccess: "User privileges updated",
|
applySuccess: "User privileges updated",
|
||||||
|
applyPartial: "The user was created, but some grants failed",
|
||||||
|
applyFailedSummary: "The operation failed",
|
||||||
applyFailed: "Execution failed: {message}",
|
applyFailed: "Execution failed: {message}",
|
||||||
|
applyFailedUnknown: "Execution failed",
|
||||||
|
standardUser: "Standard user",
|
||||||
|
standardUserHint: "Grant only the databases and privileges selected below.",
|
||||||
|
adminUser: "Administrative user",
|
||||||
|
adminUserHint: "Create an instance-level, high-privilege account.",
|
||||||
|
adminUserWarning: "This account can manage databases and other users. Review the complete SQL carefully before applying it.",
|
||||||
|
databaseAccess: "Database access",
|
||||||
|
databaseAccessHint: "Select databases and configure a separate permission level for each one.",
|
||||||
|
selectedDatabaseCount: "{count} databases",
|
||||||
|
searchDatabase: "Search databases",
|
||||||
|
loadingDatabases: "Loading databases...",
|
||||||
|
emptyDatabases: "No databases found",
|
||||||
|
loadDatabasesFailed: "Could not load databases: {message}",
|
||||||
|
prepareAuthorizationFailed: "Could not prepare database authorization: {message}",
|
||||||
|
presetReadWrite: "Read/Write",
|
||||||
|
presetReadOnly: "Read Only",
|
||||||
|
presetDdl: "DDL Only",
|
||||||
|
presetDml: "DML Only",
|
||||||
|
presetCustom: "Custom",
|
||||||
|
customPrivilegeRequired: "Select at least one privilege.",
|
||||||
|
postgresDdlHint: "PostgreSQL grants CREATE on the database/schema. Altering or dropping objects still requires ownership.",
|
||||||
|
resultSuccess: "All steps completed successfully",
|
||||||
|
resultPartial: "Partially completed",
|
||||||
|
resultFailed: "Execution failed",
|
||||||
|
closeResult: "Close",
|
||||||
|
stepCreateUser: "Create user or role",
|
||||||
|
stepGrantAdmin: "Grant administrative privileges to {user}",
|
||||||
|
stepGrantDatabase: 'Grant {user} access to database "{database}"',
|
||||||
|
stepGrantObjects: 'Grant {user} schema and object privileges in "{database}"',
|
||||||
|
stepGrantCurrentObjects: 'Grant current {scope} in schema "{schema}" to {user} in "{database}"',
|
||||||
|
stepGrantFutureObjects: 'Grant future {scope} created by the current role to {user} in "{database}"',
|
||||||
|
stepGrantFutureObjectsForOwner: 'Grant future {scope} created by {owner} to {user} in "{database}"',
|
||||||
|
scopeSchemas: "schemas",
|
||||||
|
scopeTables: "tables",
|
||||||
|
scopeSequences: "sequences",
|
||||||
|
scopeFunctions: "functions",
|
||||||
|
stepSkipped: "Skipped because a required previous step failed.",
|
||||||
},
|
},
|
||||||
damengJobAdmin: {
|
damengJobAdmin: {
|
||||||
title: "Dameng Agent Jobs",
|
title: "Dameng Agent Jobs",
|
||||||
|
|||||||
@@ -1654,6 +1654,21 @@ export default withEnglishFallback({
|
|||||||
confirmDropDatabaseTitle: "Eliminar base de datos",
|
confirmDropDatabaseTitle: "Eliminar base de datos",
|
||||||
confirmDropDatabaseMessage: '¿Estás seguro de que deseas eliminar la base de datos "{name}"? Esto borrará permanentemente la base de datos y todos sus datos.',
|
confirmDropDatabaseMessage: '¿Estás seguro de que deseas eliminar la base de datos "{name}"? Esto borrará permanentemente la base de datos y todos sus datos.',
|
||||||
createDatabaseSuccess: 'Base de datos "{name}" creada',
|
createDatabaseSuccess: 'Base de datos "{name}" creada',
|
||||||
|
createDatabasePartial: 'La base de datos "{name}" se creó, pero algunas concesiones fallaron',
|
||||||
|
createDatabaseFailed: 'No se pudo crear la base de datos "{name}"',
|
||||||
|
createDatabaseUsers: "Conceder acceso a usuarios",
|
||||||
|
createDatabaseUsersHint: "Los usuarios seleccionados recibirán acceso nativo completo después de crear la base de datos.",
|
||||||
|
createDatabaseUsersSelected: "{count} seleccionados",
|
||||||
|
createDatabaseUsersLoading: "Cargando usuarios...",
|
||||||
|
createDatabaseUsersLoadFailed: "No se pudieron cargar los usuarios: {message}",
|
||||||
|
previewCreateDatabaseSql: "Vista previa de SQL",
|
||||||
|
createDatabaseSqlPreview: "Vista previa del SQL de creación de base de datos",
|
||||||
|
applyCreateDatabaseSql: "Crear y conceder",
|
||||||
|
closeCreateDatabaseResult: "Cerrar",
|
||||||
|
createDatabaseStep: 'Crear la base de datos "{database}"',
|
||||||
|
createDatabaseGrantStep: 'Conceder a {user} acceso a la base de datos "{database}"',
|
||||||
|
createDatabaseGrantObjectsStep: 'Conceder a {user} acceso a esquemas y objetos de "{database}"',
|
||||||
|
createDatabaseStepSkipped: "Omitido porque falló un paso anterior requerido.",
|
||||||
editDatabaseProperties: "Editar propiedades de base de datos",
|
editDatabaseProperties: "Editar propiedades de base de datos",
|
||||||
editDatabasePropertiesTitle: 'Editar propiedades de base de datos: "{name}"',
|
editDatabasePropertiesTitle: 'Editar propiedades de base de datos: "{name}"',
|
||||||
editDatabasePropertiesSaving: "Guardando...",
|
editDatabasePropertiesSaving: "Guardando...",
|
||||||
@@ -1790,7 +1805,46 @@ export default withEnglishFallback({
|
|||||||
sqlPreview: "Vista previa de SQL",
|
sqlPreview: "Vista previa de SQL",
|
||||||
applySql: "Aplicar SQL",
|
applySql: "Aplicar SQL",
|
||||||
applySuccess: "Privilegios de usuario actualizados",
|
applySuccess: "Privilegios de usuario actualizados",
|
||||||
|
applyPartial: "El usuario se creó, pero algunas concesiones de base de datos fallaron",
|
||||||
|
applyFailedSummary: "La operación falló",
|
||||||
applyFailed: "Ejecución fallida: {message}",
|
applyFailed: "Ejecución fallida: {message}",
|
||||||
|
applyFailedUnknown: "Ejecución fallida",
|
||||||
|
standardUser: "Usuario estándar",
|
||||||
|
standardUserHint: "Concede solo las bases de datos y los privilegios seleccionados abajo.",
|
||||||
|
adminUser: "Usuario administrador",
|
||||||
|
adminUserHint: "Crea una cuenta de alto privilegio a nivel de instancia.",
|
||||||
|
adminUserWarning: "Esta cuenta puede administrar bases de datos y otros usuarios. Revisa el SQL completo antes de aplicarlo.",
|
||||||
|
databaseAccess: "Acceso a bases de datos",
|
||||||
|
databaseAccessHint: "Selecciona bases de datos y configura un nivel de permisos distinto para cada una.",
|
||||||
|
selectedDatabaseCount: "{count} bases de datos",
|
||||||
|
searchDatabase: "Buscar bases de datos",
|
||||||
|
loadingDatabases: "Cargando bases de datos...",
|
||||||
|
emptyDatabases: "No se encontraron bases de datos",
|
||||||
|
loadDatabasesFailed: "No se pudieron cargar las bases de datos: {message}",
|
||||||
|
prepareAuthorizationFailed: "No se pudo preparar la autorización de la base de datos: {message}",
|
||||||
|
presetReadWrite: "Lectura/Escritura",
|
||||||
|
presetReadOnly: "Solo lectura",
|
||||||
|
presetDdl: "Solo DDL",
|
||||||
|
presetDml: "Solo DML",
|
||||||
|
presetCustom: "Personalizado",
|
||||||
|
customPrivilegeRequired: "Selecciona al menos un privilegio.",
|
||||||
|
postgresDdlHint: "PostgreSQL concede CREATE sobre la base de datos y el esquema. Modificar o eliminar objetos existentes aún requiere ser su propietario.",
|
||||||
|
resultSuccess: "Todos los pasos se completaron correctamente",
|
||||||
|
resultPartial: "Completado parcialmente",
|
||||||
|
resultFailed: "Ejecución fallida",
|
||||||
|
closeResult: "Cerrar",
|
||||||
|
stepCreateUser: "Crear usuario o rol",
|
||||||
|
stepGrantAdmin: "Conceder privilegios administrativos a {user}",
|
||||||
|
stepGrantDatabase: 'Conceder a {user} acceso a la base de datos "{database}"',
|
||||||
|
stepGrantObjects: 'Conceder a {user} privilegios de esquema y objetos en "{database}"',
|
||||||
|
stepGrantCurrentObjects: 'Conceder a {user} privilegios sobre {scope} existentes del esquema "{schema}" en "{database}"',
|
||||||
|
stepGrantFutureObjects: 'Conceder a {user} privilegios sobre futuros {scope} creados por el rol actual en "{database}"',
|
||||||
|
stepGrantFutureObjectsForOwner: 'Conceder a {user} privilegios sobre futuros {scope} creados por {owner} en "{database}"',
|
||||||
|
scopeSchemas: "esquemas",
|
||||||
|
scopeTables: "tablas",
|
||||||
|
scopeSequences: "secuencias",
|
||||||
|
scopeFunctions: "funciones",
|
||||||
|
stepSkipped: "Omitido porque falló un paso anterior requerido.",
|
||||||
},
|
},
|
||||||
damengJobAdmin: {
|
damengJobAdmin: {
|
||||||
title: "Trabajos del agente Dameng",
|
title: "Trabajos del agente Dameng",
|
||||||
|
|||||||
@@ -1652,6 +1652,21 @@ export default withEnglishFallback({
|
|||||||
confirmDropDatabaseTitle: "Elimina Database",
|
confirmDropDatabaseTitle: "Elimina Database",
|
||||||
confirmDropDatabaseMessage: 'Sei sicuro di voler eliminare il database "{name}"? Questa operazione eliminerà permanentemente il database e tutti i suoi dati.',
|
confirmDropDatabaseMessage: 'Sei sicuro di voler eliminare il database "{name}"? Questa operazione eliminerà permanentemente il database e tutti i suoi dati.',
|
||||||
createDatabaseSuccess: 'Database "{name}" creato',
|
createDatabaseSuccess: 'Database "{name}" creato',
|
||||||
|
createDatabasePartial: 'Il database "{name}" è stato creato, ma alcune concessioni non sono riuscite',
|
||||||
|
createDatabaseFailed: 'Impossibile creare il database "{name}"',
|
||||||
|
createDatabaseUsers: "Concedi accesso agli utenti",
|
||||||
|
createDatabaseUsersHint: "Gli utenti selezionati riceveranno l'accesso nativo completo dopo la creazione del database.",
|
||||||
|
createDatabaseUsersSelected: "{count} selezionati",
|
||||||
|
createDatabaseUsersLoading: "Caricamento utenti...",
|
||||||
|
createDatabaseUsersLoadFailed: "Impossibile caricare gli utenti: {message}",
|
||||||
|
previewCreateDatabaseSql: "Anteprima SQL",
|
||||||
|
createDatabaseSqlPreview: "Anteprima SQL di creazione database",
|
||||||
|
applyCreateDatabaseSql: "Crea e concedi",
|
||||||
|
closeCreateDatabaseResult: "Chiudi",
|
||||||
|
createDatabaseStep: 'Crea il database "{database}"',
|
||||||
|
createDatabaseGrantStep: 'Concedi a {user} l’accesso al database "{database}"',
|
||||||
|
createDatabaseGrantObjectsStep: 'Concedi a {user} l’accesso a schemi e oggetti in "{database}"',
|
||||||
|
createDatabaseStepSkipped: "Ignorato perché un passaggio precedente richiesto non è riuscito.",
|
||||||
editDatabaseProperties: "Modifica proprietà database",
|
editDatabaseProperties: "Modifica proprietà database",
|
||||||
editDatabasePropertiesTitle: 'Modifica proprietà database: "{name}"',
|
editDatabasePropertiesTitle: 'Modifica proprietà database: "{name}"',
|
||||||
editDatabasePropertiesSaving: "Salvataggio...",
|
editDatabasePropertiesSaving: "Salvataggio...",
|
||||||
@@ -1788,7 +1803,46 @@ export default withEnglishFallback({
|
|||||||
sqlPreview: "Anteprima SQL",
|
sqlPreview: "Anteprima SQL",
|
||||||
applySql: "Applica SQL",
|
applySql: "Applica SQL",
|
||||||
applySuccess: "Privilegi utente aggiornati",
|
applySuccess: "Privilegi utente aggiornati",
|
||||||
|
applyPartial: "L'utente è stato creato, ma alcune concessioni sul database non sono riuscite",
|
||||||
|
applyFailedSummary: "Operazione non riuscita",
|
||||||
applyFailed: "Esecuzione non riuscita: {message}",
|
applyFailed: "Esecuzione non riuscita: {message}",
|
||||||
|
applyFailedUnknown: "Esecuzione non riuscita",
|
||||||
|
standardUser: "Utente standard",
|
||||||
|
standardUserHint: "Concedi solo i database e i privilegi selezionati qui sotto.",
|
||||||
|
adminUser: "Utente amministratore",
|
||||||
|
adminUserHint: "Crea un account con privilegi elevati a livello di istanza.",
|
||||||
|
adminUserWarning: "Questo account può gestire database e altri utenti. Controlla attentamente l'SQL completo prima di applicarlo.",
|
||||||
|
databaseAccess: "Accesso ai database",
|
||||||
|
databaseAccessHint: "Seleziona i database e configura un livello di autorizzazione distinto per ciascuno.",
|
||||||
|
selectedDatabaseCount: "{count} database",
|
||||||
|
searchDatabase: "Cerca database",
|
||||||
|
loadingDatabases: "Caricamento database...",
|
||||||
|
emptyDatabases: "Nessun database trovato",
|
||||||
|
loadDatabasesFailed: "Impossibile caricare i database: {message}",
|
||||||
|
prepareAuthorizationFailed: "Impossibile preparare l'autorizzazione del database: {message}",
|
||||||
|
presetReadWrite: "Lettura/Scrittura",
|
||||||
|
presetReadOnly: "Sola lettura",
|
||||||
|
presetDdl: "Solo DDL",
|
||||||
|
presetDml: "Solo DML",
|
||||||
|
presetCustom: "Personalizzato",
|
||||||
|
customPrivilegeRequired: "Seleziona almeno un privilegio.",
|
||||||
|
postgresDdlHint: "PostgreSQL concede CREATE sul database e sullo schema. La modifica o l'eliminazione di oggetti esistenti richiede comunque la proprietà.",
|
||||||
|
resultSuccess: "Tutti i passaggi sono stati completati correttamente",
|
||||||
|
resultPartial: "Completato parzialmente",
|
||||||
|
resultFailed: "Esecuzione non riuscita",
|
||||||
|
closeResult: "Chiudi",
|
||||||
|
stepCreateUser: "Crea utente o ruolo",
|
||||||
|
stepGrantAdmin: "Concedi privilegi amministrativi a {user}",
|
||||||
|
stepGrantDatabase: 'Concedi a {user} l’accesso al database "{database}"',
|
||||||
|
stepGrantObjects: 'Concedi a {user} privilegi su schema e oggetti in "{database}"',
|
||||||
|
stepGrantCurrentObjects: 'Concedi a {user} i privilegi sui {scope} esistenti nello schema "{schema}" di "{database}"',
|
||||||
|
stepGrantFutureObjects: 'Concedi a {user} i privilegi sui futuri {scope} creati dal ruolo corrente in "{database}"',
|
||||||
|
stepGrantFutureObjectsForOwner: 'Concedi a {user} i privilegi sui futuri {scope} creati da {owner} in "{database}"',
|
||||||
|
scopeSchemas: "schemi",
|
||||||
|
scopeTables: "tabelle",
|
||||||
|
scopeSequences: "sequenze",
|
||||||
|
scopeFunctions: "funzioni",
|
||||||
|
stepSkipped: "Ignorato perché un passaggio precedente richiesto non è riuscito.",
|
||||||
},
|
},
|
||||||
damengJobAdmin: {
|
damengJobAdmin: {
|
||||||
title: "Job agente Dameng",
|
title: "Job agente Dameng",
|
||||||
|
|||||||
@@ -1649,6 +1649,21 @@ export default withEnglishFallback({
|
|||||||
confirmDropDatabaseTitle: "データベースを削除",
|
confirmDropDatabaseTitle: "データベースを削除",
|
||||||
confirmDropDatabaseMessage: "本当にデータベース「{name}」をドロップ(削除)しますか?データベースとすべてのデータが永久に削除されます。",
|
confirmDropDatabaseMessage: "本当にデータベース「{name}」をドロップ(削除)しますか?データベースとすべてのデータが永久に削除されます。",
|
||||||
createDatabaseSuccess: "データベース「{name}」を作成しました",
|
createDatabaseSuccess: "データベース「{name}」を作成しました",
|
||||||
|
createDatabasePartial: "データベース「{name}」は作成されましたが、一部のユーザー権限付与に失敗しました",
|
||||||
|
createDatabaseFailed: "データベース「{name}」を作成できませんでした",
|
||||||
|
createDatabaseUsers: "アクセスを付与するユーザー",
|
||||||
|
createDatabaseUsersHint: "データベース作成後、選択したユーザーにネイティブな完全アクセス権を付与します。",
|
||||||
|
createDatabaseUsersSelected: "{count}件選択済み",
|
||||||
|
createDatabaseUsersLoading: "ユーザーを読み込み中...",
|
||||||
|
createDatabaseUsersLoadFailed: "ユーザーを読み込めませんでした: {message}",
|
||||||
|
previewCreateDatabaseSql: "SQLをプレビュー",
|
||||||
|
createDatabaseSqlPreview: "データベース作成SQLプレビュー",
|
||||||
|
applyCreateDatabaseSql: "作成して権限を付与",
|
||||||
|
closeCreateDatabaseResult: "閉じる",
|
||||||
|
createDatabaseStep: "データベース「{database}」を作成",
|
||||||
|
createDatabaseGrantStep: "{user} にデータベース「{database}」へのアクセス権を付与",
|
||||||
|
createDatabaseGrantObjectsStep: "{user} にデータベース「{database}」のスキーマとオブジェクト権限を付与",
|
||||||
|
createDatabaseStepSkipped: "必要な前のステップが失敗したためスキップしました。",
|
||||||
editDatabaseProperties: "データベースプロパティを編集",
|
editDatabaseProperties: "データベースプロパティを編集",
|
||||||
editDatabasePropertiesTitle: "データベースプロパティを編集: 「{name}」",
|
editDatabasePropertiesTitle: "データベースプロパティを編集: 「{name}」",
|
||||||
editDatabasePropertiesSaving: "保存中...",
|
editDatabasePropertiesSaving: "保存中...",
|
||||||
@@ -1823,7 +1838,46 @@ export default withEnglishFallback({
|
|||||||
sqlPreview: "SQLプレビュー",
|
sqlPreview: "SQLプレビュー",
|
||||||
applySql: "SQLを適用",
|
applySql: "SQLを適用",
|
||||||
applySuccess: "ユーザー権限を更新しました",
|
applySuccess: "ユーザー権限を更新しました",
|
||||||
|
applyPartial: "ユーザーは作成されましたが、一部のデータベース権限付与に失敗しました",
|
||||||
|
applyFailedSummary: "操作に失敗しました",
|
||||||
applyFailed: "実行に失敗しました: {message}",
|
applyFailed: "実行に失敗しました: {message}",
|
||||||
|
applyFailedUnknown: "実行に失敗しました",
|
||||||
|
standardUser: "一般ユーザー",
|
||||||
|
standardUserHint: "以下で選択したデータベースと権限のみを付与します。",
|
||||||
|
adminUser: "管理ユーザー",
|
||||||
|
adminUserHint: "インスタンスレベルの高権限アカウントを作成します。",
|
||||||
|
adminUserWarning: "このアカウントはデータベースや他のユーザーを管理できます。適用前に完全なSQLを確認してください。",
|
||||||
|
databaseAccess: "データベースアクセス",
|
||||||
|
databaseAccessHint: "データベースを選択し、それぞれに個別の権限レベルを設定します。",
|
||||||
|
selectedDatabaseCount: "{count}個のデータベース",
|
||||||
|
searchDatabase: "データベースを検索",
|
||||||
|
loadingDatabases: "データベースを読み込み中...",
|
||||||
|
emptyDatabases: "データベースが見つかりません",
|
||||||
|
loadDatabasesFailed: "データベースを読み込めませんでした: {message}",
|
||||||
|
prepareAuthorizationFailed: "データベース権限を準備できませんでした: {message}",
|
||||||
|
presetReadWrite: "読み書き",
|
||||||
|
presetReadOnly: "読み取り専用",
|
||||||
|
presetDdl: "DDLのみ",
|
||||||
|
presetDml: "DMLのみ",
|
||||||
|
presetCustom: "カスタム",
|
||||||
|
customPrivilegeRequired: "少なくとも1つの権限を選択してください。",
|
||||||
|
postgresDdlHint: "PostgreSQLではデータベースとスキーマにCREATEを付与します。既存オブジェクトの変更や削除には所有権が必要です。",
|
||||||
|
resultSuccess: "すべてのステップが正常に完了しました",
|
||||||
|
resultPartial: "一部のみ完了しました",
|
||||||
|
resultFailed: "実行に失敗しました",
|
||||||
|
closeResult: "閉じる",
|
||||||
|
stepCreateUser: "ユーザーまたはロールを作成",
|
||||||
|
stepGrantAdmin: "{user} に管理権限を付与",
|
||||||
|
stepGrantDatabase: "{user} にデータベース「{database}」の権限を付与",
|
||||||
|
stepGrantObjects: "{user} にデータベース「{database}」のスキーマとオブジェクト権限を付与",
|
||||||
|
stepGrantCurrentObjects: "{user} にデータベース「{database}」のスキーマ「{schema}」にある既存の{scope}権限を付与",
|
||||||
|
stepGrantFutureObjects: "現在のロールがデータベース「{database}」で今後作成する{scope}の権限を {user} に付与",
|
||||||
|
stepGrantFutureObjectsForOwner: "{owner} がデータベース「{database}」で今後作成する{scope}の権限を {user} に付与",
|
||||||
|
scopeSchemas: "スキーマ",
|
||||||
|
scopeTables: "テーブル",
|
||||||
|
scopeSequences: "シーケンス",
|
||||||
|
scopeFunctions: "関数",
|
||||||
|
stepSkipped: "必要な前のステップが失敗したためスキップしました。",
|
||||||
},
|
},
|
||||||
damengJobAdmin: {
|
damengJobAdmin: {
|
||||||
title: "Dameng エージェントジョブ",
|
title: "Dameng エージェントジョブ",
|
||||||
|
|||||||
@@ -1654,6 +1654,21 @@ export default withEnglishFallback({
|
|||||||
confirmDropDatabaseTitle: "Remover Banco de Dados",
|
confirmDropDatabaseTitle: "Remover Banco de Dados",
|
||||||
confirmDropDatabaseMessage: 'Tem certeza de que deseja remover o banco de dados "{name}"? Isso excluirá permanentemente o banco de dados e todos os seus dados.',
|
confirmDropDatabaseMessage: 'Tem certeza de que deseja remover o banco de dados "{name}"? Isso excluirá permanentemente o banco de dados e todos os seus dados.',
|
||||||
createDatabaseSuccess: 'Banco de dados "{name}" criado',
|
createDatabaseSuccess: 'Banco de dados "{name}" criado',
|
||||||
|
createDatabasePartial: 'O banco de dados "{name}" foi criado, mas algumas concessões falharam',
|
||||||
|
createDatabaseFailed: 'Não foi possível criar o banco de dados "{name}"',
|
||||||
|
createDatabaseUsers: "Conceder acesso aos usuários",
|
||||||
|
createDatabaseUsersHint: "Os usuários selecionados receberão acesso nativo completo após a criação do banco de dados.",
|
||||||
|
createDatabaseUsersSelected: "{count} selecionados",
|
||||||
|
createDatabaseUsersLoading: "Carregando usuários...",
|
||||||
|
createDatabaseUsersLoadFailed: "Não foi possível carregar os usuários: {message}",
|
||||||
|
previewCreateDatabaseSql: "Visualizar SQL",
|
||||||
|
createDatabaseSqlPreview: "Visualização do SQL de criação do banco de dados",
|
||||||
|
applyCreateDatabaseSql: "Criar e conceder",
|
||||||
|
closeCreateDatabaseResult: "Fechar",
|
||||||
|
createDatabaseStep: 'Criar banco de dados "{database}"',
|
||||||
|
createDatabaseGrantStep: 'Conceder a {user} acesso ao banco de dados "{database}"',
|
||||||
|
createDatabaseGrantObjectsStep: 'Conceder a {user} acesso a schemas e objetos em "{database}"',
|
||||||
|
createDatabaseStepSkipped: "Ignorado porque uma etapa anterior obrigatória falhou.",
|
||||||
editDatabaseProperties: "Editar propriedades do banco de dados",
|
editDatabaseProperties: "Editar propriedades do banco de dados",
|
||||||
editDatabasePropertiesTitle: 'Editar propriedades do banco de dados: "{name}"',
|
editDatabasePropertiesTitle: 'Editar propriedades do banco de dados: "{name}"',
|
||||||
editDatabasePropertiesSaving: "Salvando...",
|
editDatabasePropertiesSaving: "Salvando...",
|
||||||
@@ -1790,7 +1805,46 @@ export default withEnglishFallback({
|
|||||||
sqlPreview: "Visualização SQL",
|
sqlPreview: "Visualização SQL",
|
||||||
applySql: "Aplicar SQL",
|
applySql: "Aplicar SQL",
|
||||||
applySuccess: "Privilégios do usuário atualizados",
|
applySuccess: "Privilégios do usuário atualizados",
|
||||||
|
applyPartial: "O usuário foi criado, mas algumas concessões de banco de dados falharam",
|
||||||
|
applyFailedSummary: "A operação falhou",
|
||||||
applyFailed: "Execução falhou: {message}",
|
applyFailed: "Execução falhou: {message}",
|
||||||
|
applyFailedUnknown: "Falha na execução",
|
||||||
|
standardUser: "Usuário padrão",
|
||||||
|
standardUserHint: "Conceda apenas os bancos de dados e privilégios selecionados abaixo.",
|
||||||
|
adminUser: "Usuário administrador",
|
||||||
|
adminUserHint: "Crie uma conta com privilégios elevados no nível da instância.",
|
||||||
|
adminUserWarning: "Esta conta pode gerenciar bancos de dados e outros usuários. Revise cuidadosamente o SQL completo antes de aplicá-lo.",
|
||||||
|
databaseAccess: "Acesso a bancos de dados",
|
||||||
|
databaseAccessHint: "Selecione os bancos de dados e configure um nível de permissão separado para cada um.",
|
||||||
|
selectedDatabaseCount: "{count} bancos de dados",
|
||||||
|
searchDatabase: "Pesquisar bancos de dados",
|
||||||
|
loadingDatabases: "Carregando bancos de dados...",
|
||||||
|
emptyDatabases: "Nenhum banco de dados encontrado",
|
||||||
|
loadDatabasesFailed: "Não foi possível carregar os bancos de dados: {message}",
|
||||||
|
prepareAuthorizationFailed: "Não foi possível preparar a autorização do banco de dados: {message}",
|
||||||
|
presetReadWrite: "Leitura/Gravação",
|
||||||
|
presetReadOnly: "Somente leitura",
|
||||||
|
presetDdl: "Somente DDL",
|
||||||
|
presetDml: "Somente DML",
|
||||||
|
presetCustom: "Personalizado",
|
||||||
|
customPrivilegeRequired: "Selecione pelo menos um privilégio.",
|
||||||
|
postgresDdlHint: "O PostgreSQL concede CREATE no banco de dados e no schema. Alterar ou excluir objetos existentes ainda requer propriedade.",
|
||||||
|
resultSuccess: "Todas as etapas foram concluídas com sucesso",
|
||||||
|
resultPartial: "Concluído parcialmente",
|
||||||
|
resultFailed: "Falha na execução",
|
||||||
|
closeResult: "Fechar",
|
||||||
|
stepCreateUser: "Criar usuário ou função",
|
||||||
|
stepGrantAdmin: "Conceder privilégios administrativos a {user}",
|
||||||
|
stepGrantDatabase: 'Conceder a {user} acesso ao banco de dados "{database}"',
|
||||||
|
stepGrantObjects: 'Conceder a {user} privilégios de schema e objeto em "{database}"',
|
||||||
|
stepGrantCurrentObjects: 'Conceder a {user} privilégios sobre {scope} existentes no schema "{schema}" de "{database}"',
|
||||||
|
stepGrantFutureObjects: 'Conceder a {user} privilégios sobre futuros {scope} criados pela função atual em "{database}"',
|
||||||
|
stepGrantFutureObjectsForOwner: 'Conceder a {user} privilégios sobre futuros {scope} criados por {owner} em "{database}"',
|
||||||
|
scopeSchemas: "schemas",
|
||||||
|
scopeTables: "tabelas",
|
||||||
|
scopeSequences: "sequências",
|
||||||
|
scopeFunctions: "funções",
|
||||||
|
stepSkipped: "Ignorado porque uma etapa anterior obrigatória falhou.",
|
||||||
},
|
},
|
||||||
damengJobAdmin: {
|
damengJobAdmin: {
|
||||||
title: "Jobs do agente Dameng",
|
title: "Jobs do agente Dameng",
|
||||||
|
|||||||
@@ -1716,6 +1716,21 @@ export default withEnglishFallback({
|
|||||||
confirmDropDatabaseTitle: "删除数据库",
|
confirmDropDatabaseTitle: "删除数据库",
|
||||||
confirmDropDatabaseMessage: "确定要删除数据库「{name}」吗?这将永久删除该数据库及其所有数据。",
|
confirmDropDatabaseMessage: "确定要删除数据库「{name}」吗?这将永久删除该数据库及其所有数据。",
|
||||||
createDatabaseSuccess: "数据库「{name}」已创建",
|
createDatabaseSuccess: "数据库「{name}」已创建",
|
||||||
|
createDatabasePartial: "数据库「{name}」已创建,但部分用户授权失败",
|
||||||
|
createDatabaseFailed: "数据库「{name}」创建失败",
|
||||||
|
createDatabaseUsers: "关联用户授权",
|
||||||
|
createDatabaseUsersHint: "数据库创建成功后,为所选用户授予原生的完整数据库访问权限。",
|
||||||
|
createDatabaseUsersSelected: "已选择 {count} 个",
|
||||||
|
createDatabaseUsersLoading: "正在加载用户...",
|
||||||
|
createDatabaseUsersLoadFailed: "加载用户失败:{message}",
|
||||||
|
previewCreateDatabaseSql: "预览 SQL",
|
||||||
|
createDatabaseSqlPreview: "新建数据库 SQL 预览",
|
||||||
|
applyCreateDatabaseSql: "创建并授权",
|
||||||
|
closeCreateDatabaseResult: "关闭",
|
||||||
|
createDatabaseStep: "创建数据库「{database}」",
|
||||||
|
createDatabaseGrantStep: "为 {user} 授予数据库「{database}」访问权限",
|
||||||
|
createDatabaseGrantObjectsStep: "为 {user} 授予数据库「{database}」的 Schema 与对象权限",
|
||||||
|
createDatabaseStepSkipped: "因依赖的前置步骤失败而跳过。",
|
||||||
editDatabaseProperties: "编辑数据库属性",
|
editDatabaseProperties: "编辑数据库属性",
|
||||||
editDatabasePropertiesTitle: "编辑数据库属性:「{name}」",
|
editDatabasePropertiesTitle: "编辑数据库属性:「{name}」",
|
||||||
editDatabasePropertiesSaving: "正在保存...",
|
editDatabasePropertiesSaving: "正在保存...",
|
||||||
@@ -1906,7 +1921,46 @@ export default withEnglishFallback({
|
|||||||
sqlPreview: "SQL 预览",
|
sqlPreview: "SQL 预览",
|
||||||
applySql: "执行 SQL",
|
applySql: "执行 SQL",
|
||||||
applySuccess: "用户权限已更新",
|
applySuccess: "用户权限已更新",
|
||||||
|
applyPartial: "用户已创建,但部分数据库授权失败",
|
||||||
|
applyFailedSummary: "操作执行失败",
|
||||||
applyFailed: "执行失败:{message}",
|
applyFailed: "执行失败:{message}",
|
||||||
|
applyFailedUnknown: "执行失败",
|
||||||
|
standardUser: "普通用户",
|
||||||
|
standardUserHint: "仅授予下方选中的数据库和权限。",
|
||||||
|
adminUser: "管理用户",
|
||||||
|
adminUserHint: "创建实例级高权限账号。",
|
||||||
|
adminUserWarning: "该账号可以管理数据库和其他用户。执行前请仔细检查完整 SQL。",
|
||||||
|
databaseAccess: "可访问数据库",
|
||||||
|
databaseAccessHint: "选择数据库,并为每个数据库分别配置权限级别。",
|
||||||
|
selectedDatabaseCount: "已选 {count} 个数据库",
|
||||||
|
searchDatabase: "搜索数据库",
|
||||||
|
loadingDatabases: "正在加载数据库...",
|
||||||
|
emptyDatabases: "未找到数据库",
|
||||||
|
loadDatabasesFailed: "加载数据库失败:{message}",
|
||||||
|
prepareAuthorizationFailed: "准备数据库授权失败:{message}",
|
||||||
|
presetReadWrite: "读写",
|
||||||
|
presetReadOnly: "只读",
|
||||||
|
presetDdl: "仅 DDL",
|
||||||
|
presetDml: "仅 DML",
|
||||||
|
presetCustom: "自定义",
|
||||||
|
customPrivilegeRequired: "请至少选择一项权限。",
|
||||||
|
postgresDdlHint: "PostgreSQL 仅授予数据库和 Schema 的 CREATE;修改或删除已有对象仍需要所有权。",
|
||||||
|
resultSuccess: "所有步骤均执行成功",
|
||||||
|
resultPartial: "部分执行成功",
|
||||||
|
resultFailed: "执行失败",
|
||||||
|
closeResult: "关闭",
|
||||||
|
stepCreateUser: "创建用户或角色",
|
||||||
|
stepGrantAdmin: "为 {user} 授予管理权限",
|
||||||
|
stepGrantDatabase: "为 {user} 授予数据库「{database}」权限",
|
||||||
|
stepGrantObjects: "为 {user} 授予数据库「{database}」的 Schema 与对象权限",
|
||||||
|
stepGrantCurrentObjects: "为 {user} 授予数据库「{database}」中 Schema「{schema}」的现有{scope}权限",
|
||||||
|
stepGrantFutureObjects: "为 {user} 授予当前角色在数据库「{database}」中未来创建的{scope}权限",
|
||||||
|
stepGrantFutureObjectsForOwner: "为 {user} 授予 {owner} 在数据库「{database}」中未来创建的{scope}权限",
|
||||||
|
scopeSchemas: "Schema",
|
||||||
|
scopeTables: "表",
|
||||||
|
scopeSequences: "序列",
|
||||||
|
scopeFunctions: "函数",
|
||||||
|
stepSkipped: "因依赖的前置步骤失败而跳过。",
|
||||||
},
|
},
|
||||||
damengJobAdmin: {
|
damengJobAdmin: {
|
||||||
title: "达梦代理作业",
|
title: "达梦代理作业",
|
||||||
|
|||||||
@@ -1654,6 +1654,21 @@ export default withEnglishFallback({
|
|||||||
confirmDropDatabaseTitle: "刪除資料庫",
|
confirmDropDatabaseTitle: "刪除資料庫",
|
||||||
confirmDropDatabaseMessage: "確定要刪除資料庫「{name}」嗎?這將永久刪除該資料庫及其所有資料。",
|
confirmDropDatabaseMessage: "確定要刪除資料庫「{name}」嗎?這將永久刪除該資料庫及其所有資料。",
|
||||||
createDatabaseSuccess: "資料庫「{name}」已建立",
|
createDatabaseSuccess: "資料庫「{name}」已建立",
|
||||||
|
createDatabasePartial: "資料庫「{name}」已建立,但部分使用者授權失敗",
|
||||||
|
createDatabaseFailed: "資料庫「{name}」建立失敗",
|
||||||
|
createDatabaseUsers: "關聯使用者授權",
|
||||||
|
createDatabaseUsersHint: "資料庫建立成功後,為所選使用者授予原生的完整資料庫存取權限。",
|
||||||
|
createDatabaseUsersSelected: "已選擇 {count} 個",
|
||||||
|
createDatabaseUsersLoading: "正在載入使用者...",
|
||||||
|
createDatabaseUsersLoadFailed: "載入使用者失敗:{message}",
|
||||||
|
previewCreateDatabaseSql: "預覽 SQL",
|
||||||
|
createDatabaseSqlPreview: "新建資料庫 SQL 預覽",
|
||||||
|
applyCreateDatabaseSql: "建立並授權",
|
||||||
|
closeCreateDatabaseResult: "關閉",
|
||||||
|
createDatabaseStep: "建立資料庫「{database}」",
|
||||||
|
createDatabaseGrantStep: "為 {user} 授予資料庫「{database}」存取權限",
|
||||||
|
createDatabaseGrantObjectsStep: "為 {user} 授予資料庫「{database}」的 Schema 與物件權限",
|
||||||
|
createDatabaseStepSkipped: "因相依的前置步驟失敗而略過。",
|
||||||
editDatabaseProperties: "編輯資料庫屬性",
|
editDatabaseProperties: "編輯資料庫屬性",
|
||||||
editDatabasePropertiesTitle: "編輯資料庫屬性:「{name}」",
|
editDatabasePropertiesTitle: "編輯資料庫屬性:「{name}」",
|
||||||
editDatabasePropertiesSaving: "正在儲存...",
|
editDatabasePropertiesSaving: "正在儲存...",
|
||||||
@@ -3755,7 +3770,46 @@ export default withEnglishFallback({
|
|||||||
sqlPreview: "SQL 預覽",
|
sqlPreview: "SQL 預覽",
|
||||||
applySql: "套用 SQL",
|
applySql: "套用 SQL",
|
||||||
applySuccess: "使用者權限已更新",
|
applySuccess: "使用者權限已更新",
|
||||||
|
applyPartial: "使用者已建立,但部分資料庫授權失敗",
|
||||||
|
applyFailedSummary: "操作執行失敗",
|
||||||
applyFailed: "執行失敗:{message}",
|
applyFailed: "執行失敗:{message}",
|
||||||
|
applyFailedUnknown: "執行失敗",
|
||||||
|
standardUser: "一般使用者",
|
||||||
|
standardUserHint: "僅授予下方選取的資料庫和權限。",
|
||||||
|
adminUser: "管理使用者",
|
||||||
|
adminUserHint: "建立執行個體層級的高權限帳號。",
|
||||||
|
adminUserWarning: "此帳號可以管理資料庫和其他使用者。執行前請仔細檢查完整 SQL。",
|
||||||
|
databaseAccess: "可存取資料庫",
|
||||||
|
databaseAccessHint: "選擇資料庫,並為每個資料庫分別設定權限層級。",
|
||||||
|
selectedDatabaseCount: "已選 {count} 個資料庫",
|
||||||
|
searchDatabase: "搜尋資料庫",
|
||||||
|
loadingDatabases: "正在載入資料庫...",
|
||||||
|
emptyDatabases: "找不到資料庫",
|
||||||
|
loadDatabasesFailed: "載入資料庫失敗:{message}",
|
||||||
|
prepareAuthorizationFailed: "準備資料庫授權失敗:{message}",
|
||||||
|
presetReadWrite: "讀寫",
|
||||||
|
presetReadOnly: "唯讀",
|
||||||
|
presetDdl: "僅 DDL",
|
||||||
|
presetDml: "僅 DML",
|
||||||
|
presetCustom: "自訂",
|
||||||
|
customPrivilegeRequired: "請至少選擇一項權限。",
|
||||||
|
postgresDdlHint: "PostgreSQL 僅授予資料庫和 Schema 的 CREATE;修改或刪除既有物件仍需要所有權。",
|
||||||
|
resultSuccess: "所有步驟均執行成功",
|
||||||
|
resultPartial: "部分執行成功",
|
||||||
|
resultFailed: "執行失敗",
|
||||||
|
closeResult: "關閉",
|
||||||
|
stepCreateUser: "建立使用者或角色",
|
||||||
|
stepGrantAdmin: "為 {user} 授予管理權限",
|
||||||
|
stepGrantDatabase: "為 {user} 授予資料庫「{database}」權限",
|
||||||
|
stepGrantObjects: "為 {user} 授予資料庫「{database}」的 Schema 與物件權限",
|
||||||
|
stepGrantCurrentObjects: "為 {user} 授予資料庫「{database}」中 Schema「{schema}」的既有{scope}權限",
|
||||||
|
stepGrantFutureObjects: "為 {user} 授予目前角色在資料庫「{database}」中未來建立的{scope}權限",
|
||||||
|
stepGrantFutureObjectsForOwner: "為 {user} 授予 {owner} 在資料庫「{database}」中未來建立的{scope}權限",
|
||||||
|
scopeSchemas: "Schema",
|
||||||
|
scopeTables: "資料表",
|
||||||
|
scopeSequences: "序列",
|
||||||
|
scopeFunctions: "函式",
|
||||||
|
stepSkipped: "因相依的前置步驟失敗而略過。",
|
||||||
},
|
},
|
||||||
damengJobAdmin: {
|
damengJobAdmin: {
|
||||||
title: "達夢代理作業",
|
title: "達夢代理作業",
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { mysqlUserAdminProvider, postgresUserAdminProvider } from "@/lib/database/databaseUserAdmin";
|
||||||
|
import { authorizationPlanSql, buildCreateDatabaseAuthorizationPlan, buildCreateUserAuthorizationPlan, executeAuthorizationPlan } from "@/lib/database/databaseAuthorizationPlan";
|
||||||
|
|
||||||
|
describe("database authorization plans", () => {
|
||||||
|
it("grants PostgreSQL presets across user schemas and future objects", () => {
|
||||||
|
const plan = buildCreateUserAuthorizationPlan({
|
||||||
|
provider: postgresUserAdminProvider,
|
||||||
|
principal: { user: "app_user", host: "LOGIN", password: "secret", canLogin: true },
|
||||||
|
accountType: "standard",
|
||||||
|
databases: [
|
||||||
|
{
|
||||||
|
database: "app_db",
|
||||||
|
preset: "readWrite",
|
||||||
|
schemas: ["public", "app", "pg_catalog", "information_schema", "SYS_CATALOG"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
const sql = authorizationPlanSql(plan);
|
||||||
|
|
||||||
|
expect(sql).toContain('GRANT USAGE, CREATE ON SCHEMA "public" TO "app_user";');
|
||||||
|
expect(sql).toContain('GRANT USAGE, CREATE ON SCHEMA "app" TO "app_user";');
|
||||||
|
expect(sql).toContain('GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON ALL TABLES IN SCHEMA "app" TO "app_user";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON TABLES TO "app_user";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES GRANT USAGE, CREATE ON SCHEMAS TO "app_user";');
|
||||||
|
expect(sql).toContain('GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA "app" TO "app_user";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES GRANT EXECUTE ON FUNCTIONS TO "app_user";');
|
||||||
|
expect(sql).not.toContain('SCHEMA "pg_catalog"');
|
||||||
|
expect(sql).not.toContain('SCHEMA "information_schema"');
|
||||||
|
expect(sql).not.toContain('SCHEMA "SYS_CATALOG"');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("includes current and future PostgreSQL object grants after database creation", () => {
|
||||||
|
const plan = buildCreateDatabaseAuthorizationPlan({
|
||||||
|
provider: postgresUserAdminProvider,
|
||||||
|
database: "app_db",
|
||||||
|
createSql: 'CREATE DATABASE "app_db";',
|
||||||
|
users: [{ user: "app_user", host: "LOGIN" }],
|
||||||
|
});
|
||||||
|
const sql = authorizationPlanSql(plan);
|
||||||
|
|
||||||
|
expect(sql).toContain('GRANT ALL PRIVILEGES ON DATABASE "app_db" TO "app_user";');
|
||||||
|
expect(sql).toContain('GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA "public" TO "app_user";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES GRANT ALL PRIVILEGES ON SCHEMAS TO "app_user";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES GRANT ALL PRIVILEGES ON TABLES TO "app_user";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES GRANT ALL PRIVILEGES ON SEQUENCES TO "app_user";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES GRANT ALL PRIVILEGES ON FUNCTIONS TO "app_user";');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("cross-grants future PostgreSQL schemas and objects between linked users", () => {
|
||||||
|
const plan = buildCreateDatabaseAuthorizationPlan({
|
||||||
|
provider: postgresUserAdminProvider,
|
||||||
|
database: "app_db",
|
||||||
|
createSql: 'CREATE DATABASE "app_db";',
|
||||||
|
users: [
|
||||||
|
{ user: "alice", host: "LOGIN" },
|
||||||
|
{ user: "bob", host: "LOGIN" },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
const sql = authorizationPlanSql(plan);
|
||||||
|
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES FOR ROLE "alice" GRANT ALL PRIVILEGES ON SCHEMAS TO "bob";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES FOR ROLE "alice" GRANT ALL PRIVILEGES ON TABLES TO "bob";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES FOR ROLE "bob" GRANT ALL PRIVILEGES ON SEQUENCES TO "alice";');
|
||||||
|
expect(sql).toContain('ALTER DEFAULT PRIVILEGES FOR ROLE "bob" GRANT ALL PRIVILEGES ON FUNCTIONS TO "alice";');
|
||||||
|
expect(plan.steps.every((step) => !step.sql.includes("\n"))).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps PostgreSQL read-only sequence access non-mutating", () => {
|
||||||
|
const plan = buildCreateUserAuthorizationPlan({
|
||||||
|
provider: postgresUserAdminProvider,
|
||||||
|
principal: { user: "reader", host: "LOGIN", password: "secret", canLogin: true },
|
||||||
|
accountType: "standard",
|
||||||
|
databases: [{ database: "app_db", preset: "readOnly", schemas: ["app"] }],
|
||||||
|
});
|
||||||
|
const sql = authorizationPlanSql(plan);
|
||||||
|
|
||||||
|
expect(sql).toContain('GRANT SELECT ON ALL SEQUENCES IN SCHEMA "app" TO "reader";');
|
||||||
|
expect(sql).not.toContain('GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA "app" TO "reader";');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps MySQL database grants scoped to the selected database", () => {
|
||||||
|
const plan = buildCreateDatabaseAuthorizationPlan({
|
||||||
|
provider: mysqlUserAdminProvider,
|
||||||
|
database: "app-db",
|
||||||
|
createSql: "CREATE DATABASE `app-db`;",
|
||||||
|
users: [{ user: "app", host: "%" }],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(authorizationPlanSql(plan)).toContain("GRANT ALL PRIVILEGES ON `app-db`.* TO 'app'@'%';");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps creation plans usable when authorization capabilities are unavailable", () => {
|
||||||
|
const createOnlyProvider = { ...mysqlUserAdminProvider, grantPrivilegesSql: undefined };
|
||||||
|
const databasePlan = buildCreateDatabaseAuthorizationPlan({
|
||||||
|
provider: createOnlyProvider,
|
||||||
|
database: "app_db",
|
||||||
|
createSql: "CREATE DATABASE `app_db`;",
|
||||||
|
users: [{ user: "app", host: "%" }],
|
||||||
|
});
|
||||||
|
const unsupportedUserPlan = buildCreateUserAuthorizationPlan({
|
||||||
|
provider: { ...createOnlyProvider, createUserSql: undefined },
|
||||||
|
principal: { user: "app", host: "%", password: "secret" },
|
||||||
|
accountType: "standard",
|
||||||
|
databases: [{ database: "app_db", preset: "readOnly" }],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(databasePlan.steps.map((step) => step.operation)).toEqual(["createDatabase"]);
|
||||||
|
expect(unsupportedUserPlan.steps).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps result metadata structured for IPv6 hosts and colon-containing databases", () => {
|
||||||
|
const plan = buildCreateUserAuthorizationPlan({
|
||||||
|
provider: mysqlUserAdminProvider,
|
||||||
|
principal: { user: "app", host: "2001:db8::1", password: "secret" },
|
||||||
|
accountType: "standard",
|
||||||
|
databases: [{ database: "db:prod", preset: "readOnly" }],
|
||||||
|
});
|
||||||
|
const grant = plan.steps.find((step) => step.operation === "grantDatabase");
|
||||||
|
|
||||||
|
expect(grant).toMatchObject({ subject: "app@2001:db8::1", targetDatabase: "db:prod" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reports PostgreSQL object grants independently", async () => {
|
||||||
|
const plan = buildCreateDatabaseAuthorizationPlan({
|
||||||
|
provider: postgresUserAdminProvider,
|
||||||
|
database: "app_db",
|
||||||
|
createSql: 'CREATE DATABASE "app_db";',
|
||||||
|
users: [{ user: "app_user", host: "LOGIN" }],
|
||||||
|
});
|
||||||
|
const results = await executeAuthorizationPlan(plan, async (step) => {
|
||||||
|
if (step.operation === "grantCurrentObjects" && step.objectScope === "tables") {
|
||||||
|
return [{ columns: ["error"], rows: [["table grant failed"]], affected_rows: 0, execution_time_ms: 0, execution_error: true }];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(results.find((result) => result.step.operation === "grantCurrentObjects" && result.step.objectScope === "tables")?.status).toBe("failed");
|
||||||
|
expect(results.find((result) => result.step.operation === "grantCurrentObjects" && result.step.objectScope === "sequences")?.status).toBe("success");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("skips dependent grants after a failed creation step", async () => {
|
||||||
|
const plan = buildCreateDatabaseAuthorizationPlan({
|
||||||
|
provider: mysqlUserAdminProvider,
|
||||||
|
database: "app_db",
|
||||||
|
createSql: "CREATE DATABASE `app_db`;",
|
||||||
|
users: [{ user: "app", host: "%" }],
|
||||||
|
});
|
||||||
|
const results = await executeAuthorizationPlan(plan, async (step) => {
|
||||||
|
if (step.id === "create-database") throw new Error("create failed");
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(results.map((result) => result.status)).toEqual(["failed", "skipped"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,423 @@
|
|||||||
|
import type { QueryResult } from "@/types/database";
|
||||||
|
import { mysqlUserAccount, quoteMySqlIdentifier, quotePostgresIdentifier, type CreatePrincipalInput, type DatabaseUserAdminProvider, type DatabaseUserIdentity } from "@/lib/database/databaseUserAdmin";
|
||||||
|
|
||||||
|
export type AuthorizationAccountType = "standard" | "admin";
|
||||||
|
export type AuthorizationPreset = "readWrite" | "readOnly" | "ddl" | "dml" | "custom";
|
||||||
|
export type AuthorizationStepOperation = "createUser" | "grantAdmin" | "createDatabase" | "grantDatabase" | "grantCurrentObjects" | "grantFutureObjects";
|
||||||
|
export type AuthorizationObjectScope = "schemas" | "tables" | "sequences" | "functions";
|
||||||
|
|
||||||
|
export interface DatabaseAuthorizationSelection {
|
||||||
|
database: string;
|
||||||
|
preset: AuthorizationPreset;
|
||||||
|
privileges?: string[];
|
||||||
|
schemas?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AuthorizationPlanStep {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
database: string;
|
||||||
|
sql: string;
|
||||||
|
dependsOn?: string[];
|
||||||
|
operation: AuthorizationStepOperation;
|
||||||
|
subject?: string;
|
||||||
|
targetDatabase?: string;
|
||||||
|
objectScope?: AuthorizationObjectScope;
|
||||||
|
schema?: string;
|
||||||
|
owner?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AuthorizationPlan {
|
||||||
|
steps: AuthorizationPlanStep[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AuthorizationStepStatus = "success" | "failed" | "skipped";
|
||||||
|
|
||||||
|
export interface AuthorizationStepResult {
|
||||||
|
step: AuthorizationPlanStep;
|
||||||
|
status: AuthorizationStepStatus;
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateUserAuthorizationPlanInput {
|
||||||
|
provider: DatabaseUserAdminProvider;
|
||||||
|
principal: CreatePrincipalInput;
|
||||||
|
accountType: AuthorizationAccountType;
|
||||||
|
databases: DatabaseAuthorizationSelection[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateDatabaseAuthorizationPlanInput {
|
||||||
|
provider: DatabaseUserAdminProvider;
|
||||||
|
database: string;
|
||||||
|
createSql: string;
|
||||||
|
users: DatabaseUserIdentity[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const MYSQL_PRESETS: Record<Exclude<AuthorizationPreset, "custom">, string[]> = {
|
||||||
|
readOnly: ["SELECT", "SHOW VIEW"],
|
||||||
|
dml: ["SELECT", "INSERT", "UPDATE", "DELETE"],
|
||||||
|
ddl: ["CREATE", "DROP", "ALTER", "INDEX", "REFERENCES", "SHOW VIEW", "CREATE VIEW", "CREATE ROUTINE", "ALTER ROUTINE", "TRIGGER", "EVENT", "CREATE TEMPORARY TABLES"],
|
||||||
|
readWrite: ["SELECT", "INSERT", "UPDATE", "DELETE", "CREATE", "DROP", "ALTER", "INDEX", "REFERENCES", "EXECUTE", "SHOW VIEW", "CREATE VIEW", "CREATE ROUTINE", "ALTER ROUTINE", "TRIGGER", "EVENT", "CREATE TEMPORARY TABLES", "LOCK TABLES"],
|
||||||
|
};
|
||||||
|
|
||||||
|
const POSTGRES_PRESETS: Record<Exclude<AuthorizationPreset, "custom">, string[]> = {
|
||||||
|
readOnly: ["SELECT"],
|
||||||
|
dml: ["SELECT", "INSERT", "UPDATE", "DELETE"],
|
||||||
|
ddl: ["CREATE"],
|
||||||
|
readWrite: ["SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", "EXECUTE", "CREATE", "TEMPORARY"],
|
||||||
|
};
|
||||||
|
|
||||||
|
export function authorizationPresetPrivileges(provider: DatabaseUserAdminProvider, preset: AuthorizationPreset, custom: string[] = []): string[] {
|
||||||
|
if (preset === "custom") return uniquePrivileges(custom);
|
||||||
|
return [...(provider.dialect === "mysql" ? MYSQL_PRESETS[preset] : POSTGRES_PRESETS[preset])];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function authorizationPrivileges(provider: DatabaseUserAdminProvider): string[] {
|
||||||
|
const privilegesForScope = provider.privilegesForScope;
|
||||||
|
if (!privilegesForScope) return [];
|
||||||
|
if (provider.dialect === "mysql") return Array.from(privilegesForScope("mysql"));
|
||||||
|
return uniquePrivileges([...privilegesForScope("database"), ...privilegesForScope("schema"), ...privilegesForScope("table"), "EXECUTE", "USAGE", "UPDATE"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildCreateUserAuthorizationPlan(input: CreateUserAuthorizationPlanInput): AuthorizationPlan {
|
||||||
|
const createStepId = "create-user";
|
||||||
|
// Connection-specific providers expose only the admin operations supported by that server.
|
||||||
|
if (!input.provider.createUserSql) return { steps: [] };
|
||||||
|
const steps: AuthorizationPlanStep[] = [
|
||||||
|
{
|
||||||
|
id: createStepId,
|
||||||
|
label: "create user",
|
||||||
|
database: "",
|
||||||
|
sql: input.provider.createUserSql(input.principal),
|
||||||
|
operation: "createUser",
|
||||||
|
subject: input.provider.label(input.principal),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
if (input.accountType === "admin") {
|
||||||
|
if (input.provider.dialect === "mysql" && !input.provider.grantPrivilegesSql) return { steps };
|
||||||
|
steps.push({
|
||||||
|
id: "grant-admin",
|
||||||
|
label: `grant admin privileges to ${input.provider.label(input.principal)}`,
|
||||||
|
database: "",
|
||||||
|
sql: adminPrincipalGrantSql(input.provider, input.principal),
|
||||||
|
dependsOn: [createStepId],
|
||||||
|
operation: "grantAdmin",
|
||||||
|
subject: input.provider.label(input.principal),
|
||||||
|
});
|
||||||
|
return { steps };
|
||||||
|
}
|
||||||
|
|
||||||
|
const identity: DatabaseUserIdentity = {
|
||||||
|
user: input.principal.user,
|
||||||
|
host: input.principal.host,
|
||||||
|
};
|
||||||
|
if (!input.provider.grantPrivilegesSql) return { steps };
|
||||||
|
for (const selection of input.databases) {
|
||||||
|
const database = selection.database.trim();
|
||||||
|
if (!database) continue;
|
||||||
|
const privileges = authorizationPresetPrivileges(input.provider, selection.preset, selection.privileges);
|
||||||
|
if (input.provider.dialect === "mysql") {
|
||||||
|
steps.push({
|
||||||
|
id: `grant-${steps.length}`,
|
||||||
|
label: `grant ${input.provider.label(identity)} access to ${database}`,
|
||||||
|
database: "",
|
||||||
|
sql: input.provider.grantPrivilegesSql({ user: identity, privileges, database, table: "*", scope: "mysql" }),
|
||||||
|
dependsOn: [createStepId],
|
||||||
|
operation: "grantDatabase",
|
||||||
|
subject: input.provider.label(identity),
|
||||||
|
targetDatabase: database,
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
steps.push(...postgresDatabaseAuthorizationSteps(identity, database, privileges, selection.schemas ?? ["public"], createStepId, steps.length));
|
||||||
|
}
|
||||||
|
return { steps };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildCreateDatabaseAuthorizationPlan(input: CreateDatabaseAuthorizationPlanInput): AuthorizationPlan {
|
||||||
|
const createStepId = "create-database";
|
||||||
|
const steps: AuthorizationPlanStep[] = [
|
||||||
|
{
|
||||||
|
id: createStepId,
|
||||||
|
label: `create database ${input.database}`,
|
||||||
|
database: "",
|
||||||
|
sql: input.createSql,
|
||||||
|
operation: "createDatabase",
|
||||||
|
targetDatabase: input.database,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const postgresUsers: DatabaseUserIdentity[] = [];
|
||||||
|
const postgresDatabaseGrantIds = new Map<string, string>();
|
||||||
|
if (!input.provider.grantPrivilegesSql) return { steps };
|
||||||
|
for (const user of input.users) {
|
||||||
|
if (input.provider.dialect === "mysql") {
|
||||||
|
steps.push({
|
||||||
|
id: `grant-${steps.length}`,
|
||||||
|
label: `grant ${input.provider.label(user)} access to ${input.database}`,
|
||||||
|
database: "",
|
||||||
|
sql: `GRANT ALL PRIVILEGES ON ${quoteMySqlIdentifier(input.database)}.* TO ${mysqlUserAccount(user)};`,
|
||||||
|
dependsOn: [createStepId],
|
||||||
|
operation: "grantDatabase",
|
||||||
|
subject: input.provider.label(user),
|
||||||
|
targetDatabase: input.database,
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
postgresUsers.push(user);
|
||||||
|
const role = quotePostgresIdentifier(user.user);
|
||||||
|
const database = quotePostgresIdentifier(input.database);
|
||||||
|
const databaseGrantId = `grant-database-${steps.length}`;
|
||||||
|
postgresDatabaseGrantIds.set(user.user, databaseGrantId);
|
||||||
|
steps.push({
|
||||||
|
id: databaseGrantId,
|
||||||
|
label: `grant ${input.provider.label(user)} access to ${input.database}`,
|
||||||
|
database: "",
|
||||||
|
sql: `GRANT ALL PRIVILEGES ON DATABASE ${database} TO ${role};`,
|
||||||
|
dependsOn: [createStepId],
|
||||||
|
operation: "grantDatabase",
|
||||||
|
subject: input.provider.label(user),
|
||||||
|
targetDatabase: input.database,
|
||||||
|
});
|
||||||
|
steps.push(...postgresFullCurrentObjectSteps(user, input.database, "public", [createStepId, databaseGrantId], `create-${steps.length}`));
|
||||||
|
steps.push(...postgresFullFutureObjectSteps(user, input.database, undefined, [createStepId, databaseGrantId], `creator-${steps.length}`));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const owner of postgresUsers) {
|
||||||
|
for (const grantee of postgresUsers) {
|
||||||
|
if (owner.user === grantee.user) continue;
|
||||||
|
const databaseGrantId = postgresDatabaseGrantIds.get(grantee.user);
|
||||||
|
steps.push(...postgresFullFutureObjectSteps(grantee, input.database, owner.user, [createStepId, ...(databaseGrantId ? [databaseGrantId] : [])], `owner-${steps.length}`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { steps };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function authorizationPlanSql(plan: AuthorizationPlan): string {
|
||||||
|
return plan.steps
|
||||||
|
.map((step) => {
|
||||||
|
const target = step.database ? `database: ${step.database}` : "connection scope";
|
||||||
|
return `-- ${step.label} (${target})\n${step.sql}`;
|
||||||
|
})
|
||||||
|
.join("\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function executeAuthorizationPlan(plan: AuthorizationPlan, execute: (step: AuthorizationPlanStep) => Promise<QueryResult[]>): Promise<AuthorizationStepResult[]> {
|
||||||
|
const results: AuthorizationStepResult[] = [];
|
||||||
|
const failed = new Set<string>();
|
||||||
|
for (const step of plan.steps) {
|
||||||
|
if (step.dependsOn?.some((dependency) => failed.has(dependency))) {
|
||||||
|
failed.add(step.id);
|
||||||
|
results.push({ step, status: "skipped" });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const queryResults = await execute(step);
|
||||||
|
const error = queryResults.find((result) => result.execution_error === true);
|
||||||
|
if (error) {
|
||||||
|
failed.add(step.id);
|
||||||
|
results.push({ step, status: "failed", message: queryResultMessage(error) });
|
||||||
|
} else {
|
||||||
|
results.push({ step, status: "success" });
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
failed.add(step.id);
|
||||||
|
results.push({ step, status: "failed", message: error?.message || String(error) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function authorizationPlanStatus(results: AuthorizationStepResult[]): "success" | "partial" | "failed" {
|
||||||
|
const successes = results.filter((result) => result.status === "success").length;
|
||||||
|
const failures = results.filter((result) => result.status === "failed").length;
|
||||||
|
if (failures === 0) return "success";
|
||||||
|
return successes > 0 ? "partial" : "failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
function adminPrincipalGrantSql(provider: DatabaseUserAdminProvider, principal: CreatePrincipalInput): string {
|
||||||
|
if (provider.dialect === "mysql") {
|
||||||
|
return `GRANT ALL PRIVILEGES ON *.* TO ${mysqlUserAccount(principal)} WITH GRANT OPTION;`;
|
||||||
|
}
|
||||||
|
return `ALTER ROLE ${quotePostgresIdentifier(principal.user)} SUPERUSER CREATEDB CREATEROLE;`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function postgresDatabaseAuthorizationSteps(user: DatabaseUserIdentity, databaseName: string, privileges: string[], schemaNames: string[], createStepId: string, index: number): AuthorizationPlanStep[] {
|
||||||
|
const role = quotePostgresIdentifier(user.user);
|
||||||
|
const database = quotePostgresIdentifier(databaseName);
|
||||||
|
const privilegeSet = new Set(uniquePrivileges(privileges));
|
||||||
|
const databasePrivileges = uniquePrivileges(["CONNECT", ...(privilegeSet.has("CREATE") ? ["CREATE"] : []), ...(privilegeSet.has("TEMPORARY") ? ["TEMPORARY"] : [])]);
|
||||||
|
const databaseStepId = `grant-database-${index}`;
|
||||||
|
const steps: AuthorizationPlanStep[] = [
|
||||||
|
{
|
||||||
|
id: databaseStepId,
|
||||||
|
label: `grant ${user.user} access to ${databaseName}`,
|
||||||
|
database: "",
|
||||||
|
sql: `GRANT ${databasePrivileges.join(", ")} ON DATABASE ${database} TO ${role};`,
|
||||||
|
dependsOn: [createStepId],
|
||||||
|
operation: "grantDatabase",
|
||||||
|
subject: user.user,
|
||||||
|
targetDatabase: databaseName,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const schemas = uniqueSchemas(schemaNames);
|
||||||
|
if (schemas.length > 0) {
|
||||||
|
const tablePrivileges = [...privilegeSet].filter((privilege) => ["SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER"].includes(privilege));
|
||||||
|
const sequencePrivileges = privilegeSet.has("UPDATE") ? "USAGE, SELECT, UPDATE" : privilegeSet.has("INSERT") ? "USAGE, SELECT" : privilegeSet.has("SELECT") ? "SELECT" : "";
|
||||||
|
for (const [schemaIndex, schemaName] of schemas.entries()) {
|
||||||
|
const schema = quotePostgresIdentifier(schemaName);
|
||||||
|
steps.push(
|
||||||
|
authorizationObjectStep({
|
||||||
|
id: `grant-schema-${index}-${schemaIndex}`,
|
||||||
|
user,
|
||||||
|
databaseName,
|
||||||
|
schema: schemaName,
|
||||||
|
objectScope: "schemas",
|
||||||
|
sql: `GRANT USAGE${privilegeSet.has("CREATE") ? ", CREATE" : ""} ON SCHEMA ${schema} TO ${role};`,
|
||||||
|
dependsOn: [createStepId, databaseStepId],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
if (tablePrivileges.length > 0) {
|
||||||
|
const tablePrivilegeSql = tablePrivileges.join(", ");
|
||||||
|
steps.push(
|
||||||
|
authorizationObjectStep({
|
||||||
|
id: `grant-tables-${index}-${schemaIndex}`,
|
||||||
|
user,
|
||||||
|
databaseName,
|
||||||
|
schema: schemaName,
|
||||||
|
objectScope: "tables",
|
||||||
|
sql: `GRANT ${tablePrivilegeSql} ON ALL TABLES IN SCHEMA ${schema} TO ${role};`,
|
||||||
|
dependsOn: [createStepId, databaseStepId],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (sequencePrivileges) {
|
||||||
|
steps.push(
|
||||||
|
authorizationObjectStep({
|
||||||
|
id: `grant-sequences-${index}-${schemaIndex}`,
|
||||||
|
user,
|
||||||
|
databaseName,
|
||||||
|
schema: schemaName,
|
||||||
|
objectScope: "sequences",
|
||||||
|
sql: `GRANT ${sequencePrivileges} ON ALL SEQUENCES IN SCHEMA ${schema} TO ${role};`,
|
||||||
|
dependsOn: [createStepId, databaseStepId],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (privilegeSet.has("EXECUTE")) {
|
||||||
|
steps.push(
|
||||||
|
authorizationObjectStep({
|
||||||
|
id: `grant-functions-${index}-${schemaIndex}`,
|
||||||
|
user,
|
||||||
|
databaseName,
|
||||||
|
schema: schemaName,
|
||||||
|
objectScope: "functions",
|
||||||
|
sql: `GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA ${schema} TO ${role};`,
|
||||||
|
dependsOn: [createStepId, databaseStepId],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const schemaPrivileges = privilegeSet.has("CREATE") ? "USAGE, CREATE" : "USAGE";
|
||||||
|
steps.push(authorizationFutureObjectStep({ id: `grant-default-schemas-${index}`, user, databaseName, objectScope: "schemas", privileges: schemaPrivileges, dependsOn: [createStepId, databaseStepId] }));
|
||||||
|
if (tablePrivileges.length > 0) {
|
||||||
|
steps.push(authorizationFutureObjectStep({ id: `grant-default-tables-${index}`, user, databaseName, objectScope: "tables", privileges: tablePrivileges.join(", "), dependsOn: [createStepId, databaseStepId] }));
|
||||||
|
}
|
||||||
|
if (sequencePrivileges) {
|
||||||
|
steps.push(authorizationFutureObjectStep({ id: `grant-default-sequences-${index}`, user, databaseName, objectScope: "sequences", privileges: sequencePrivileges, dependsOn: [createStepId, databaseStepId] }));
|
||||||
|
}
|
||||||
|
if (privilegeSet.has("EXECUTE")) {
|
||||||
|
steps.push(authorizationFutureObjectStep({ id: `grant-default-functions-${index}`, user, databaseName, objectScope: "functions", privileges: "EXECUTE", dependsOn: [createStepId, databaseStepId] }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AuthorizationObjectStepInput {
|
||||||
|
id: string;
|
||||||
|
user: DatabaseUserIdentity;
|
||||||
|
databaseName: string;
|
||||||
|
objectScope: AuthorizationObjectScope;
|
||||||
|
sql: string;
|
||||||
|
dependsOn: string[];
|
||||||
|
schema?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function authorizationObjectStep(input: AuthorizationObjectStepInput): AuthorizationPlanStep {
|
||||||
|
return {
|
||||||
|
id: input.id,
|
||||||
|
label: `grant current ${input.objectScope} to ${input.user.user} in ${input.databaseName}`,
|
||||||
|
database: input.databaseName,
|
||||||
|
sql: input.sql,
|
||||||
|
dependsOn: input.dependsOn,
|
||||||
|
operation: "grantCurrentObjects",
|
||||||
|
subject: input.user.user,
|
||||||
|
targetDatabase: input.databaseName,
|
||||||
|
objectScope: input.objectScope,
|
||||||
|
schema: input.schema,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AuthorizationFutureObjectStepInput {
|
||||||
|
id: string;
|
||||||
|
user: DatabaseUserIdentity;
|
||||||
|
databaseName: string;
|
||||||
|
objectScope: AuthorizationObjectScope;
|
||||||
|
privileges: string;
|
||||||
|
dependsOn: string[];
|
||||||
|
owner?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function authorizationFutureObjectStep(input: AuthorizationFutureObjectStepInput): AuthorizationPlanStep {
|
||||||
|
const ownerSql = input.owner ? ` FOR ROLE ${quotePostgresIdentifier(input.owner)}` : "";
|
||||||
|
return {
|
||||||
|
id: input.id,
|
||||||
|
label: `grant future ${input.objectScope} from ${input.owner ?? "current role"} to ${input.user.user} in ${input.databaseName}`,
|
||||||
|
database: input.databaseName,
|
||||||
|
sql: `ALTER DEFAULT PRIVILEGES${ownerSql} GRANT ${input.privileges} ON ${input.objectScope.toUpperCase()} TO ${quotePostgresIdentifier(input.user.user)};`,
|
||||||
|
dependsOn: input.dependsOn,
|
||||||
|
operation: "grantFutureObjects",
|
||||||
|
subject: input.user.user,
|
||||||
|
targetDatabase: input.databaseName,
|
||||||
|
objectScope: input.objectScope,
|
||||||
|
owner: input.owner,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function postgresFullCurrentObjectSteps(user: DatabaseUserIdentity, databaseName: string, schemaName: string, dependsOn: string[], idPrefix: string): AuthorizationPlanStep[] {
|
||||||
|
const role = quotePostgresIdentifier(user.user);
|
||||||
|
const schema = quotePostgresIdentifier(schemaName);
|
||||||
|
return [
|
||||||
|
authorizationObjectStep({ id: `${idPrefix}-schema`, user, databaseName, schema: schemaName, objectScope: "schemas", sql: `GRANT ALL PRIVILEGES ON SCHEMA ${schema} TO ${role};`, dependsOn }),
|
||||||
|
authorizationObjectStep({ id: `${idPrefix}-tables`, user, databaseName, schema: schemaName, objectScope: "tables", sql: `GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA ${schema} TO ${role};`, dependsOn }),
|
||||||
|
authorizationObjectStep({ id: `${idPrefix}-sequences`, user, databaseName, schema: schemaName, objectScope: "sequences", sql: `GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA ${schema} TO ${role};`, dependsOn }),
|
||||||
|
authorizationObjectStep({ id: `${idPrefix}-functions`, user, databaseName, schema: schemaName, objectScope: "functions", sql: `GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA ${schema} TO ${role};`, dependsOn }),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function postgresFullFutureObjectSteps(user: DatabaseUserIdentity, databaseName: string, owner: string | undefined, dependsOn: string[], idPrefix: string): AuthorizationPlanStep[] {
|
||||||
|
return (["schemas", "tables", "sequences", "functions"] as const).map((objectScope) => authorizationFutureObjectStep({ id: `${idPrefix}-default-${objectScope}`, user, databaseName, objectScope, privileges: "ALL PRIVILEGES", dependsOn, owner }));
|
||||||
|
}
|
||||||
|
|
||||||
|
function uniqueSchemas(schemaNames: string[]): string[] {
|
||||||
|
return Array.from(
|
||||||
|
new Set(
|
||||||
|
schemaNames
|
||||||
|
.map((schema) => schema.trim())
|
||||||
|
.filter((schema) => {
|
||||||
|
const normalized = schema.toLowerCase();
|
||||||
|
return !!schema && normalized !== "information_schema" && normalized !== "sys_catalog" && !normalized.startsWith("pg_");
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function uniquePrivileges(privileges: string[]): string[] {
|
||||||
|
return Array.from(new Set(privileges.map((privilege) => privilege.trim().toUpperCase()).filter(Boolean)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryResultMessage(result: QueryResult): string {
|
||||||
|
return String(result.rows[0]?.[0] ?? "Execution failed");
|
||||||
|
}
|
||||||
@@ -47,7 +47,11 @@ export interface DatabaseUserAdminProvider {
|
|||||||
defaultPrivilegesForScope?(scope: PrivilegeScope): string[];
|
defaultPrivilegesForScope?(scope: PrivilegeScope): string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MYSQL_COMMON_PRIVILEGES = ["SELECT", "INSERT", "UPDATE", "DELETE", "CREATE", "DROP", "ALTER", "INDEX", "REFERENCES", "EXECUTE", "SHOW VIEW", "TRIGGER", "EVENT", "CREATE TEMPORARY TABLES"] as const;
|
export const MYSQL_USER_ADMIN_TYPES = new Set<DatabaseType>(["mysql", "goldendb"]);
|
||||||
|
export const KINGBASE_USER_ADMIN_TYPES = new Set<DatabaseType>(["kingbase"]);
|
||||||
|
export const POSTGRES_USER_ADMIN_TYPES = new Set<DatabaseType>(["postgres", "gaussdb", "highgo", "kwdb", "opengauss", "questdb", "vastbase"]);
|
||||||
|
|
||||||
|
export const MYSQL_COMMON_PRIVILEGES = ["SELECT", "INSERT", "UPDATE", "DELETE", "CREATE", "DROP", "ALTER", "INDEX", "REFERENCES", "EXECUTE", "SHOW VIEW", "CREATE VIEW", "CREATE ROUTINE", "ALTER ROUTINE", "TRIGGER", "EVENT", "CREATE TEMPORARY TABLES", "LOCK TABLES"] as const;
|
||||||
export const STARROCKS_TABLE_PRIVILEGES = ["SELECT", "INSERT", "UPDATE", "DELETE", "ALTER", "DROP", "EXPORT", "ALL"] as const;
|
export const STARROCKS_TABLE_PRIVILEGES = ["SELECT", "INSERT", "UPDATE", "DELETE", "ALTER", "DROP", "EXPORT", "ALL"] as const;
|
||||||
|
|
||||||
export const POSTGRES_DATABASE_PRIVILEGES = ["CONNECT", "CREATE", "TEMPORARY"] as const;
|
export const POSTGRES_DATABASE_PRIVILEGES = ["CONNECT", "CREATE", "TEMPORARY"] as const;
|
||||||
|
|||||||
Reference in new issue
Block a user