mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-15 21:03:47 +00:00
feat: allow sharing opkssh-authenticated hosts
This commit is contained in:
@@ -128,10 +128,10 @@ router.post(
|
|||||||
return res.status(403).json({ error: "Not host owner" });
|
return res.status(403).json({ error: "Not host owner" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!host[0].credentialId) {
|
if (!host[0].credentialId && host[0].authType !== "opkssh") {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
error:
|
error:
|
||||||
"Only hosts using credentials can be shared. Please create a credential and assign it to this host before sharing.",
|
"Only hosts using credentials or OPKSSH can be shared. Please create a credential and assign it to this host before sharing.",
|
||||||
code: "CREDENTIAL_REQUIRED_FOR_SHARING",
|
code: "CREDENTIAL_REQUIRED_FOR_SHARING",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -203,6 +203,7 @@ router.post(
|
|||||||
.delete(sharedCredentials)
|
.delete(sharedCredentials)
|
||||||
.where(eq(sharedCredentials.hostAccessId, existing[0].id));
|
.where(eq(sharedCredentials.hostAccessId, existing[0].id));
|
||||||
|
|
||||||
|
if (host[0].credentialId) {
|
||||||
const { SharedCredentialManager } =
|
const { SharedCredentialManager } =
|
||||||
await import("../../utils/shared-credential-manager.js");
|
await import("../../utils/shared-credential-manager.js");
|
||||||
const sharedCredManager = SharedCredentialManager.getInstance();
|
const sharedCredManager = SharedCredentialManager.getInstance();
|
||||||
@@ -221,6 +222,7 @@ router.post(
|
|||||||
userId,
|
userId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
databaseLogger.info("Permission granted", {
|
databaseLogger.info("Permission granted", {
|
||||||
operation: "rbac_permission_grant",
|
operation: "rbac_permission_grant",
|
||||||
adminId: userId,
|
adminId: userId,
|
||||||
@@ -249,6 +251,7 @@ router.post(
|
|||||||
await import("../../utils/shared-credential-manager.js");
|
await import("../../utils/shared-credential-manager.js");
|
||||||
const sharedCredManager = SharedCredentialManager.getInstance();
|
const sharedCredManager = SharedCredentialManager.getInstance();
|
||||||
|
|
||||||
|
if (host[0].credentialId) {
|
||||||
if (targetType === "user") {
|
if (targetType === "user") {
|
||||||
await sharedCredManager.createSharedCredentialForUser(
|
await sharedCredManager.createSharedCredentialForUser(
|
||||||
result.lastInsertRowid as number,
|
result.lastInsertRowid as number,
|
||||||
@@ -264,6 +267,7 @@ router.post(
|
|||||||
userId,
|
userId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
databaseLogger.success("Host shared successfully", {
|
databaseLogger.success("Host shared successfully", {
|
||||||
operation: "rbac_host_share_success",
|
operation: "rbac_host_share_success",
|
||||||
userId,
|
userId,
|
||||||
|
|||||||
Reference in New Issue
Block a user