feat(scan): add guided Linux agent setup in administration
This commit is contained in:
@@ -90,10 +90,22 @@ export default async function instanceAgentRoutes(server: FastifyInstance) {
|
||||
createdAt: instanceAgents.createdAt,
|
||||
})
|
||||
|
||||
return {
|
||||
agent,
|
||||
token,
|
||||
}
|
||||
reply.header("Cache-Control", "no-store")
|
||||
return { agent, token }
|
||||
})
|
||||
|
||||
server.post<{ Params: { id: string } }>("/instance-agents/:id/token", async (req, reply) => {
|
||||
if (!requireAdmin(req, reply)) return
|
||||
const id = z.string().uuid().parse(req.params.id)
|
||||
const token = createAgentToken()
|
||||
const [agent] = await server.db
|
||||
.update(instanceAgents)
|
||||
.set({ tokenPrefix: token.slice(0, 24), tokenHash: hashToken(token), lastSeenAt: null, updatedAt: new Date() })
|
||||
.where(eq(instanceAgents.id, id))
|
||||
.returning({ id: instanceAgents.id })
|
||||
if (!agent) return reply.code(404).send({ error: "Agent not found" })
|
||||
reply.header("Cache-Control", "no-store")
|
||||
return { token }
|
||||
})
|
||||
|
||||
server.patch<{ Params: { id: string } }>("/instance-agents/:id", async (req, reply) => {
|
||||
|
||||
Reference in New Issue
Block a user