mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(servers): harden pairing and run linked-server sessions in the UI
Replace the plaintext pairing exchange with a nonce and HMAC proof plus AES-256-GCM encrypted credentials, bumping links to v2. Track session ownership per linked server so activity, session picker, transcript, MCP and skills views work against remote servers. Share encrypted secret access, event routing and URL helpers across backend, shared and CLI.
This commit is contained in:
1 parent
c591c15743
commit
f566556fd6
77 files changed
+3170
-702
No files matched your search
@@ -142,6 +142,44 @@ describe('opencode server proxy routes', () => {
|
||||
expect(fetchMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('returns 400 for repeated encoded traversal that survives segment decoding', async () => {
|
||||
const fetchMock = createFetchMock()
|
||||
const app = buildApp(fetchMock as unknown as typeof fetch)
|
||||
|
||||
const res = await app.request('/api/opencode/servers/srv_1/api/%25252e%25252e/config')
|
||||
|
||||
expect(res.status).toBe(400)
|
||||
expect(await res.json()).toEqual({ error: 'Invalid proxy path' })
|
||||
expect(fetchMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('returns 400 when a prefixed base URL would be escaped by path normalization', async () => {
|
||||
getConnectionMock.mockReturnValue({ baseUrl: 'http://remote.example:4096/prefix', authorization: basicAuth })
|
||||
const fetchMock = createFetchMock()
|
||||
const app = buildApp(fetchMock as unknown as typeof fetch)
|
||||
|
||||
const res = await app.request(
|
||||
'/api/opencode/servers/srv_1/api/session/%25252e%25252e/%25252e%25252e/config',
|
||||
)
|
||||
|
||||
expect(res.status).toBe(400)
|
||||
expect(await res.json()).toEqual({ error: 'Invalid proxy path' })
|
||||
expect(fetchMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('proxies a normal API path under a prefixed base URL unchanged', async () => {
|
||||
getConnectionMock.mockReturnValue({ baseUrl: 'http://remote.example:4096/prefix', authorization: basicAuth })
|
||||
const fetchMock = createFetchMock()
|
||||
const app = buildApp(fetchMock as unknown as typeof fetch)
|
||||
|
||||
const res = await app.request('/api/opencode/servers/srv_1/api/session')
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1)
|
||||
const [url] = fetchMock.mock.calls[0] as [string, RequestInit]
|
||||
expect(url).toBe('http://remote.example:4096/prefix/api/session')
|
||||
})
|
||||
|
||||
it('returns 404 for upstream paths outside /api', async () => {
|
||||
const fetchMock = createFetchMock()
|
||||
const app = buildApp(fetchMock as unknown as typeof fetch)
|
||||
|
||||
Reference in new issue
Block a user