@@ -56,6 +56,7 @@ import type { RedisClientType } from 'redis';
5656import type { Logger } from 'winston' ;
5757
5858import { createServerApp } from './app' ;
59+ import { TrueForgeAuthorizer , type Authorizer } from './auth/authorizer' ;
5960import { createAuthenticator } from './auth/createAuthenticator' ;
6061import { resolveRequestContext } from './auth/identity' ;
6162import { initOidc } from './auth/oidc' ;
@@ -86,6 +87,7 @@ import { EventSubscriptionRegistry } from './runtime/event-subscription';
8687import { printStandaloneStartupBanner } from './startupBanner' ;
8788import { parsePerServerMcpHeaders , X_TFG_MCP_HEADERS } from './truefoundry/perServerMcpHeaders' ;
8889import { TrueFoundryAgentStore } from './truefoundry/TrueFoundryAgentStore' ;
90+ import { TrueFoundryAuthorizer } from './truefoundry/TrueFoundryAuthorizer' ;
8991import { TrueFoundryMcpServerStore } from './truefoundry/TrueFoundryMcpServerStore' ;
9092import { TrueFoundryModelProviderStore } from './truefoundry/TrueFoundryModelProviderStore' ;
9193import { TrueFoundryServiceFoundryServerClient } from './truefoundry/TrueFoundryServiceFoundryServerClient' ;
@@ -387,25 +389,30 @@ async function createServerRuntime<TTransaction>(persistence: ServerPersistence<
387389 const oidcClient = await initOidc ( oidc ) ;
388390
389391 let authenticator ;
392+ let authorizer : Authorizer ;
390393 const mode = getTrueForgeMode ( configuration ) ;
391394 if ( mode === TrueForgeMode . TrueFoundry ) {
392395 if ( ! isTrueFoundryModeEnabled ( configuration ) ) {
393396 throw new Error ( 'TrueFoundry mode requires TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL' ) ;
394397 }
398+ const trueFoundryClient = new TrueFoundryServiceFoundryServerClient ( {
399+ serviceFoundryServerUrl : configuration . TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL ,
400+ logger,
401+ httpTimeoutMs : configuration . TRUEFOUNDRY_SERVICEFOUNDRY_HTTP_TIMEOUT_MS ,
402+ httpAgentTimeoutMs : configuration . TRUEFOUNDRY_SERVICEFOUNDRY_HTTP_AGENT_TIMEOUT_MS ,
403+ tls : { enabled : configuration . TRUEFOUNDRY_MTLS_ENABLED , dir : configuration . TRUEFOUNDRY_MTLS_CERTS_DIR } ,
404+ } ) ;
395405 authenticator = createAuthenticator ( {
396406 mode : TrueForgeMode . TrueFoundry ,
397- trueFoundryClient : new TrueFoundryServiceFoundryServerClient ( {
398- serviceFoundryServerUrl : configuration . TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL ,
399- logger,
400- httpTimeoutMs : configuration . TRUEFOUNDRY_SERVICEFOUNDRY_HTTP_TIMEOUT_MS ,
401- httpAgentTimeoutMs : configuration . TRUEFOUNDRY_SERVICEFOUNDRY_HTTP_AGENT_TIMEOUT_MS ,
402- tls : { enabled : configuration . TRUEFOUNDRY_MTLS_ENABLED , dir : configuration . TRUEFOUNDRY_MTLS_CERTS_DIR } ,
403- } ) ,
407+ trueFoundryClient,
404408 } ) ;
409+ authorizer = new TrueFoundryAuthorizer ( trueFoundryClient ) ;
405410 } else if ( mode === TrueForgeMode . Oidc ) {
406411 authenticator = createAuthenticator ( { mode : TrueForgeMode . Oidc } ) ;
412+ authorizer = new TrueForgeAuthorizer ( ) ;
407413 } else {
408414 authenticator = createAuthenticator ( { mode : TrueForgeMode . Standalone } ) ;
415+ authorizer = new TrueForgeAuthorizer ( ) ;
409416 }
410417
411418 // Standalone is one process, so it owns the control loops too.
@@ -441,6 +448,7 @@ async function createServerRuntime<TTransaction>(persistence: ServerPersistence<
441448 logger,
442449 oidcClient,
443450 authenticator,
451+ authorizer,
444452 } ) ;
445453
446454 return { activeTurns, app, controller, destroyDb, redis, requestReplyRouter } ;
0 commit comments