mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-31 07:35:24 +00:00
feat: host lock api so a plugin can load hosts from a config file (#1581)
This commit is contained in:
1 parent
1cdbfc674c
commit
2c785fe35b
34 files changed
+1388
-52
No files matched your search
@@ -85,6 +85,11 @@ import {
|
||||
type PlannedProtocolAuth,
|
||||
} from "../../hosts/protocol-auth/protocol-auth.js";
|
||||
import { findHostProtocol } from "../../hosts/protocol-auth/registry.js";
|
||||
import {
|
||||
manualCreateBlockedBy,
|
||||
requireManualCreate,
|
||||
requireUnlockedHost,
|
||||
} from "../../hosts/locks.js";
|
||||
import {
|
||||
mergeStoredSshOptions,
|
||||
parseTerminalConfig,
|
||||
@@ -157,6 +162,7 @@ router.post(
|
||||
authenticateJWT,
|
||||
permissionManager.requirePermission("hosts.create"),
|
||||
requireDataAccess,
|
||||
requireManualCreate,
|
||||
requireHostEnrollmentAccessForPath,
|
||||
upload.single("key"),
|
||||
async (req: Request, res: Response) => {
|
||||
@@ -736,6 +742,7 @@ router.put(
|
||||
authenticateJWT,
|
||||
permissionManager.requirePermission("hosts.edit"),
|
||||
requireDataAccess,
|
||||
requireUnlockedHost,
|
||||
upload.single("key"),
|
||||
async (req: Request, res: Response) => {
|
||||
const hostId = Array.isArray(req.params.id)
|
||||
@@ -1205,6 +1212,27 @@ router.put(
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /host/policy:
|
||||
* get:
|
||||
* summary: Host creation policy
|
||||
* description: Whether hosts can be added by hand, or a plugin manages them all.
|
||||
* tags:
|
||||
* - SSH
|
||||
* responses:
|
||||
* 200:
|
||||
* description: "{ manualCreate, blockedBy? } where blockedBy is the managing plugin's name."
|
||||
*/
|
||||
router.get("/policy", authenticateJWT, (_req: Request, res: Response) => {
|
||||
const blocked = manualCreateBlockedBy();
|
||||
res.json(
|
||||
blocked
|
||||
? { manualCreate: false, blockedBy: blocked.pluginName }
|
||||
: { manualCreate: true },
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /host/db/host:
|
||||
@@ -1702,6 +1730,7 @@ router.delete(
|
||||
authenticateJWT,
|
||||
permissionManager.requirePermission("hosts.delete"),
|
||||
requireDataAccess,
|
||||
requireUnlockedHost,
|
||||
async (req: Request, res: Response) => {
|
||||
const userId = (req as AuthenticatedRequest).userId;
|
||||
const hostId = Array.isArray(req.params.id)
|
||||
|
||||
Reference in new issue
Block a user