Skip to content

Commit 619934d

Browse files
authored
Authenticate plugin routes (#2720)
1 parent 97c1399 commit 619934d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/node/plugin.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as semver from "semver"
66
import * as pluginapi from "../../typings/pluginapi"
77
import { HttpCode, HttpError } from "../common/http"
88
import { version } from "./constants"
9-
import { replaceTemplates } from "./http"
9+
import { ensureAuthenticated, replaceTemplates } from "./http"
1010
import { proxy } from "./proxy"
1111
import * as util from "./util"
1212
import { Router as WsRouter, WebsocketRouter, wss } from "./wsRouter"
@@ -122,10 +122,10 @@ export class PluginAPI {
122122
public mount(r: express.Router, wr: express.Router): void {
123123
for (const [, p] of this.plugins) {
124124
if (p.router) {
125-
r.use(`${p.routerPath}`, p.router())
125+
r.use(`${p.routerPath}`, ensureAuthenticated, p.router())
126126
}
127127
if (p.wsRouter) {
128-
wr.use(`${p.routerPath}`, (p.wsRouter() as WebsocketRouter).router)
128+
wr.use(`${p.routerPath}`, ensureAuthenticated, (p.wsRouter() as WebsocketRouter).router)
129129
}
130130
}
131131
}

src/node/routes/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { plural } from "../../common/util"
1212
import { AuthType, DefaultedArgs } from "../cli"
1313
import { rootPath } from "../constants"
1414
import { Heart } from "../heart"
15-
import { redirect, replaceTemplates } from "../http"
15+
import { ensureAuthenticated, redirect, replaceTemplates } from "../http"
1616
import { PluginAPI } from "../plugin"
1717
import { getMediaMime, paths } from "../util"
1818
import { wrapper } from "../wrapper"
@@ -119,7 +119,7 @@ export const register = async (
119119
const pluginApi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir)
120120
await pluginApi.loadPlugins()
121121
pluginApi.mount(app, wsApp)
122-
app.use("/api/applications", apps.router(pluginApi))
122+
app.use("/api/applications", ensureAuthenticated, apps.router(pluginApi))
123123
wrapper.onDispose(() => pluginApi.dispose())
124124
}
125125

0 commit comments

Comments
 (0)