Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(gfs): propagate user generation to upload relay

Alfredo Lopez4ebd15416c85
diff --git a/control-api/src/routes/external/gfs.ts b/control-api/src/routes/external/gfs.ts
index 096eb6500..1cb0de8b4 100644
--- a/control-api/src/routes/external/gfs.ts
+++ b/control-api/src/routes/external/gfs.ts
@@ -1169,7 +1169,16 @@ async function proxyUploadToGfsc(
query?: Record<string, string | undefined>
): Promise<void> {
const claims = req.externalAuth!
- const { token } = signGfsToken({ subject: claims.userId, drive, scopes: [GFS_WRITE_SCOPE] })
+ const { token } = signGfsToken({
+ subject: claims.userId,
+ drive,
+ scopes: [GFS_WRITE_SCOPE],
+ // GFSC resolves user authority against users.lifecycle_version on every
+ // request. The session generation must cross this relay boundary or a
+ // valid external session is rejected as an un-fenced user token.
+ authGeneration: claims.authGeneration,
+ principalType: 'user',
+ })
const targetUrl = new URL(`${config.gfscWriteBaseUrl.replace(/\/+$/, '')}${gfscPath}`)
for (const [key, value] of Object.entries(query ?? {})) {
if (value !== undefined && value !== '') targetUrl.searchParams.set(key, value)
diff --git a/control-api/test/routes.externalGfs.test.ts b/control-api/test/routes.externalGfs.test.ts
index 5767eeaad..f6a2838a7 100644
--- a/control-api/test/routes.externalGfs.test.ts
+++ b/control-api/test/routes.externalGfs.test.ts
@@ -758,6 +758,8 @@ describe('indexed upload relay canonical drive', () => {
subject: U1,
drive: 'main',
scopes: ['gfs.write'],
+ authGeneration: 1,
+ principalType: 'user',
})
expect(fetchMock).toHaveBeenCalledTimes(1)
})
@@ -833,7 +835,13 @@ describe('indexed upload relay canonical drive', () => {
expect(fetchMock).toHaveBeenCalledTimes(9)
expect(mockSignGfsToken).toHaveBeenCalledTimes(9)
for (const [input] of mockSignGfsToken.mock.calls) {
- expect(input).toEqual({ subject: U1, drive: 'archive', scopes: ['gfs.write'] })
+ expect(input).toEqual({
+ subject: U1,
+ drive: 'archive',
+ scopes: ['gfs.write'],
+ authGeneration: 1,
+ principalType: 'user',
+ })
}
expect(fetchMock.mock.calls.map(call => String(call[0]))).toEqual([
'http://gfsc-writer.gfs.svc:8087/v1/capabilities',